Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Higher lower strategy

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

    Higher lower strategy

    Can someone help me please:

    I have developed a simple strategy: on a 15 minute chart, i go long when the current price go above the high from previous 15 minute candle.
    This works fine, but the long is only triggered after the current 15 minute candle is finished.
    Is there a way to go long immediately when the price go above the previous high?

    Thanks in advance,


    Gummy

    #2
    Hello Gummy,

    Welcome to the NinjaTrader forums!

    During backtesting, orders are always submitted at next bar open following a condition.

    During real-time, you can set CalculateOnBarClose = false to have orders submitted as soon as conditions evaluate to true.

    Discrepancies Real Time versus a Backtest.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryanm, thanks for your fast reply.


      Gummy

      Comment


        #4
        Dear,

        It doesn't seem to work. Only triggered (arrow up) after the current 15 minute candle is finished. Here's my strategy. Can someone tell me what is wrong?
        Thanks in advance.
        #region Variables

        privateint myInput0 = 1;

        protectedoverridevoid Initialize()
        {
        CalculateOnBarClose =
        false;
        }

        protectedoverridevoid OnBarUpdate()
        {
        if (Low[0] < Low[1])
        {
        DrawArrowDown(
        "My down arrow" + CurrentBar, false, 0, High[0], Color.Red);
        }

        if (High[0] > High[1])
        {
        DrawArrowUp(
        "My up arrow" + CurrentBar, false, 0, Low[0], Color.Lime);
        }
        }

        Comment


          #5
          Hi Gummy,

          A couple items here:

          1) Make sure you have enough bars in the data series you are accessing

          You may need to add a current bar check such as if (CurrentBar < 1) return;

          2) In an historical environment, all actions take place on the bar after the condition evaluates true. You can have the arrow draw one bar back by adjusting the barsAgo parameter and the price that the arrow is drawn as well.

          Example of this in DrawArrowDown():
          DrawArrowDown("My down arrow" + CurrentBar, false, 1, High[1], Color.Red);
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Dear RyanM,

            I'm running the strategy in real time and i have Ninjatrader running all day, so enough bars of data. I don't use it for backtesting.
            But still doesn't work. Any suggestions?

            Thanks

            Comment


              #7
              What doesn't work specifically?

              Are there any error messages in the log tab of the control center?
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                No error messages in the log tab. The strategy works fine, but the arrows are only drawn after the current 15 minute candle is completely finished.
                And i want the arrow drawn immediately when the price go above the previous high. Or below the previous low of course.

                Thanks

                Comment


                  #9
                  Yours should work as you expect as long as:
                  • Running Real-Time
                  • CalculateOnBarClose = false
                  • You're using your original code (Not my suggested code, which draws arrow on the bar they occurred historically)
                  You may just need to recompile your indicators and reapply to your chart.

                  If you're still not seeing these results, let us know which version of the platform you're using and whether this is an indicator or strategy. I'll get a sample file of this for you to try.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Dear RyanM,

                    I just did a compile on the strategy and now it works fine!

                    Thank you,

                    Regards

                    Gummy

                    Comment


                      #11
                      Glad to hear! Thanks for the update, Gummy.
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      648 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X