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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        578 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X