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 EvaisDery, Today, 05:44 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post EvaisDery  
                  Started by JerryWar, 11-19-2016, 08:14 AM
                  3 responses
                  2,070 views
                  0 likes
                  Last Post tradertom2012  
                  Started by capt34, Today, 03:46 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post capt34
                  by capt34
                   
                  Started by wuannetraam, Today, 12:22 AM
                  1 response
                  12 views
                  0 likes
                  Last Post wuannetraam  
                  Started by TGOG1, Yesterday, 03:02 PM
                  2 responses
                  27 views
                  0 likes
                  Last Post TGOG1
                  by TGOG1
                   
                  Working...
                  X