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 pmachiraju, 11-01-2023, 04:46 AM
                  8 responses
                  149 views
                  0 likes
                  Last Post rehmans
                  by rehmans
                   
                  Started by mattbsea, Today, 05:44 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post mattbsea  
                  Started by RideMe, 04-07-2024, 04:54 PM
                  6 responses
                  33 views
                  0 likes
                  Last Post RideMe
                  by RideMe
                   
                  Started by tkaboris, Today, 05:13 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post tkaboris  
                  Started by GussJ, 03-04-2020, 03:11 PM
                  16 responses
                  3,283 views
                  0 likes
                  Last Post Leafcutter  
                  Working...
                  X