• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry trigger above High

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

    Entry trigger above High

    I have attached a chart image for visual. Im using OnBarUpdate=false. With the code below I'm trying to trigger a long trade after there is a MA crossover 2 bars back and when price moves above the high of the bar 2 bars back or the high of the bar at the crossover point.

    if (SMA(Fast)[2] > SMA(Slow)[2] && SMA(Fast)[3] < SMA(Slow)[3] && Close[0] > High[2] )
    { EnterLong(100, ""); }

    As you can see from the chart the 3rd bar after the crossover takes out the high of the bar at the crossover but the entry doesn't trigger till the 4th bar after the crossover? Im looking for it to trigger on the 3rd bar in real time as the price moves above the high 2 bars back.

    I figured having OnBarUpdate=false and using Close[0] > High[2] would take care of this. Should I be using something else other than Close[0]. Is there another Data command such as Last[0] for last price so that as soon as price moves above the high it triggers?
    Attached Files

    #2
    zachj, no Close[0] with COBC set to false would be fine for last price. So your screenshot attached was generated in realtime or backtesting?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      That is backtesting, sorry for confusion, when i said realtime i just meant like the second or few seconds after it goes above the high im looking for it to trigger the long but it always seems to be triggering on the next bar instead?

      Comment


        #4
        For backtesting I would expect that outcome seen, for realtime running or MarketReplay on COBC = false the condition can trigger intrabar if all other parts are satisfied on this bar.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Ok gotcha..so for backtesting cobc setting does not take effect. Im using 15m bars for primary and even tried creating a 2nd series of 1min to make it trigger within the 15m bar but it still waits till the next 15m bar. Not sure if i am supposed to use barsinprogress=0 or 1 because the cross part of the code needs to use primary but the code to trigger above the high based on 1min needs to use secondary.

          Comment


            #6
            You would need to make sure to send the order in historical from the added one min series then, so BIP = 1. You can still access the highs and price data from the primary timeframe when processing here, for example try something like -

            if (SMA(BarsArray[0], Fast)[2] > SMA(BarsArray[0], Slow)[2] && SMA(BarsArray[0], Fast)[3] < SMA(, BarsArray[0]Slow)[3] && Close[0] > Highs[0][2] )
            { EnterLong(100, ""); }
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Ya that did it. Thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Erhard, Today, 04:24 AM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_ChrisSch  
              Started by rontronimous, Yesterday, 05:55 PM
              2 responses
              18 views
              0 likes
              Last Post rontronimous  
              Started by brunoviveiros, Today, 04:26 AM
              0 responses
              2 views
              0 likes
              Last Post brunoviveiros  
              Started by StevenNelson, 11-19-2019, 05:39 AM
              3 responses
              17 views
              0 likes
              Last Post brucerobinson  
              Started by guidoisot, Today, 03:01 AM
              0 responses
              8 views
              0 likes
              Last Post guidoisot  
              Working...
              X