Announcement

Collapse
No announcement yet.

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?


    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


        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?"

            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.

                Comment


                  #9
                  I will do it. Thanks you

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Yesterday, 05:17 AM
                  0 responses
                  54 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  130 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  72 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  44 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  49 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X