Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

entry and prices

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

    entry and prices

    hi,

    illustration: if(Close[0]>Close[1]) EnterLong(); i know that if this condition is true trade price used in back test is the next bar's open...i wanted to know what method or programming logic do i use to execute EnterLong() only if the next bar's open meets some other condition, for example if i wanted the next bar's Open[-1]>High[0], i know i can't do this but this the logic of what i'm attempting to do. if there's a method will you please provide and if there's logic please "tell" me but don't write the code for me! i trying to learn.

    thanks

    #2
    d.allen101,

    This is not possible because NinjaTrader will not let you look into the future. If you are going to place the order it will go in regardless of the open price.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      i didn't explain myself well. here's my signal logic: if(Close[0]>Close[1]), now if this condition is true i want to take the trade (EnterLong()) only if the next bar's open which in theory would be Open[-1] is greater than the current bar's high which is High[0]. otherwise condition is false. something like this: if(Close[0]>Close[1] && Open[-1]>High[0]) EnterLong();

      Comment


        #4
        d.allen101,

        You cannot look into the future. When you place the order at the end of the bar there is no notion of the opening price of the next bar. The order gets filled at the open because that is the next tradeable spot.

        At the time you submit the order you have no idea what the next open price is going to be.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          i realize i can't look into the future but what i'm saying is there's a condition placed on where the future opening price will be RELATIVE to the current price bar's high, low or whatever current price point i choose. for example if you get a signal right now on a 5 min bar that instructs you to go long at the NEXT 5 min bar's open "BUT" only if the next 5 min bar's open is greater than the CURRENT 5 mins bars high why is this not doable?

          Comment


            #6
            No. You cannot look into the future therefore you cannot run any checks against a future open price. Your order is already in place at the end of the bar. Then it gets filled at the open. At the end of the bar there is no such thing as checking the opening price because it does not exist.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              hey josh sorry...i understand, i'm essentially entering a market order by using EnterLong(). well how would do i go about saying: "enter market order only if the market opens higher"?

              Comment


                #8
                d.allen101,

                You check Open[0] > Open[1], but as expected, the order won't go in until the next bar.

                You are asking for intrabar granularity that just doesn't exist in a backtest. You have OHLC at one moment in time (close of the bar) so you can't base any logic off of the open point in time.

                You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  hey josh i understand what you were trying to explain now...thanks for being patient with me. i'm new to coding and trading so sometimes things that are relatively simple may take me a minute or two before i understand them conceputually. but thanks again for helping me out (i learned something new today)!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  633 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  364 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  567 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  568 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X