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

CrossAbove vs manual cross

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

    CrossAbove vs manual cross

    Hello,

    These two statements return different number of entries (totally different), why these two are not equivalent?

    Statement 1 is just the CrossAbove function.
    Statement 2 says if:
    close one period ago is under the SMA one period ago
    AND
    current close is greater than current sma



    Statement 1:
    CrossAbove(Closes[2][0],SMA(BarsArray[2],15),1)


    Statement 2:
    Closes[2][1] < SMA(BarsArray[2],15)[1] &&
    Closes[2][0] > SMA(BarsArray[2],15)[0]


    Thanks,

    #2
    Hello Morafra,

    Thank you for your post.

    This is because CrossAbove() condition checks for being less than or equal to the previous value rather than just less than

    This would be the test against the CrossAbove in the same manner as Statement 2:
    if(Closes[2][1] <= SMA(BarsArray[2], 15)[1]
    && Closes[2][0] > SMA(BarsArray[2], 15)[0])

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      The CrossAbove returns about 3,300 trades whereas the updated Statement 2 returns about 30,000 trades.

      You can try this on your end with any strategy.

      Are there any other restrictions built in the CrossAbove function other than the actual crossover?

      Thanks,

      Comment


        #4
        Morfra,

        You are testing two different things here in that they are not the same test. CrossAbove() condition checking in side the method looks at Less than or Equal to the previous value.

        Your's is only checking when its Less than the previous.

        I would not expect to get similar results.

        What restrictions are you referring to?
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Today, 11:02 AM
        1 response
        1 view
        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
        15 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by lorem, Today, 09:18 AM
        2 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        4 responses
        30 views
        0 likes
        Last Post geddyisodin  
        Working...
        X