Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

The algorithm does not work comparing DAYBar prices against 4 minutes prices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    The algorithm does not work comparing DAYBar prices against 4 minutes prices

    I am trying to create a strategy that compares the close of the previous day against the close of the 4 minutes bar. It does not work at all. Would anybody help me please?

    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Minute, 5); // BarsArray[1]
    AddDataSeries(Data.BarsPeriodType.Day, 1); // BarsArray[2]
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 0 || CurrentBars[2] < 99)
    return;

    if ( Close[0] < Closes[2][1])
    {
    PlaceLongEntry();
    }
    }

    #2
    Hello Jorge.andres.o,

    Thanks for your post.

    When you run your strategy, do you see any errors listed in the NinjaTrader control centers "Log" tab that relates to the strategy?

    Your strategy adds 2 data series (5 minutes and day bars) and then the chart bars are 4-minute bars, is that correct?

    In your current bars check you are testing if the chart bars [0] are less than zero OR the daily bars are less than 99. Is your charts data series set to greater than 99 days?


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      There are no errors. It just doesn’t work at all or doesn’t work as expected.

      For instance, it only submit short orders regardless of the position of the price with respect to the daily open.

      Comment


        #4
        Hello Jorge.andres.o ,

        Thanks for your reply.

        "For instance, it only submit short orders regardless of the position of the price with respect to the daily open."

        If your strategy is placing orders but they are the wrong orders then you will need to debug the strategy to find out where the logic is incorrect.

        I suggest starting with printing out the values of Close[0] < Closes[2][1] and check against the chart(s) to verify the values.

        If you find that the values are correct then you would need to debug your method "PlaceLongEntry();" to see why it is not placing orders. I assume you have a similar method for placing short orders so again you would need to debug that to find out why it is not performing as expected.

        Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I already did it. It is not getting the daily bar information.
          I think I am calling it right. Ain’t I?

          Comment


            #6
            Hello Jorge.andres.o,

            Thanks for your reply.

            If the prints show that you are not getting daily bar data then you could not expect the code to execute properly.

            Earlier I asked this question, "In your current bars check you are testing if the chart bars [0] are less than zero OR the daily bars are less than 99. Is your charts data series set to greater than 99 days?"

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I dont understand the question

              Comment


                #8
                Hello Jorge.andres.o,

                Thanks for your reply.

                In your code, you are checking to see if there are less than 99 days and if so it should return (not process your script)

                if (CurrentBars[0] < 0 || CurrentBars[2] < 99)
                return;

                I would suggest setting that to be a smaller value such as 1.

                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  I will do it. Thanks you

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by lightsun47, Today, 03:51 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post lightsun47  
                  Started by 00nevest, Today, 02:27 PM
                  1 response
                  12 views
                  0 likes
                  Last Post 00nevest  
                  Started by futtrader, 04-21-2024, 01:50 AM
                  4 responses
                  46 views
                  0 likes
                  Last Post futtrader  
                  Started by Option Whisperer, Today, 09:55 AM
                  1 response
                  14 views
                  0 likes
                  Last Post bltdavid  
                  Started by port119, Today, 02:43 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post port119
                  by port119
                   
                  Working...
                  X