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 LillyMarv, Today, 06:47 AM
        1 response
        10 views
        0 likes
        Last Post marcus2300  
        Started by michi08, Today, 08:51 AM
        1 response
        7 views
        0 likes
        Last Post bltdavid  
        Started by awwenzovs, Today, 08:03 AM
        1 response
        9 views
        0 likes
        Last Post bltdavid  
        Started by nicthe, Today, 07:38 AM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by algospoke, 02-19-2024, 03:25 PM
        4 responses
        38 views
        0 likes
        Last Post gummybar  
        Working...
        X