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 cre8able, Yesterday, 07:24 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by cocoescala, 10-12-2018, 11:02 PM
        6 responses
        939 views
        0 likes
        Last Post Jquiroz1975  
        Started by gbourque, Today, 06:39 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by benmarkal, Yesterday, 12:52 PM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X