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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        168 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        324 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        250 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        350 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X