Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Range Logic

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

    #16
    Would Code 2 be the way " to enter a long position at 10 ticks below the closing price of the "crossover" bar that occurred within the last 5 bars"?
    Code 1
    if (CountIf(delegate {return CrossAbove(WMA(Fast), WMA(Slow), 1);}, 5) >= 1)
    EnterLongLimit(DefaultQuantity, Close[0] + -10 * TickSize, "Crossover Buy");

    Code 2
    int barsAgo = MRO(delegate {return CrossAbove(WMA(Fast), WMA(Slow), 1);}, 1, 5);
    if (barsAgo > -1)
    EnterLongLimit(DefaultQuantity, Close[barsAgo] + -10 * TickSize, "Crossover Buy");


    Comment


      #17
      Yes, looks like the code matches the description you're looking for.

      You can also use least recent occurrence if you want to get the barsAgo value for the oldest occurrence of the crossover condition for the lookback period.

      Ryan M.NinjaTrader Customer Service

      Comment


        #18
        Thanks, I'll give a try.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        153 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        133 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        128 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X