Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 bmartz, Today, 09:30 AM
        2 responses
        11 views
        0 likes
        Last Post bltdavid  
        Started by f.saeidi, Today, 11:02 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by geotrades1, Today, 10:02 AM
        4 responses
        12 views
        0 likes
        Last Post geotrades1  
        Started by rajendrasubedi2023, Today, 09:50 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by lorem, Today, 09:18 AM
        2 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X