Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

simple moving averages that cross

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

    simple moving averages that cross

    I had this coded in NT7 and did some backtesting with promising results. I took a break and am now getting back into trading futures on NT8.

    if (CrossAbove(smaFast, smaSlow, 1)). This is the only example I have to work with.

    Its three simple moving averages. in NinjaTrader7 it is written like this:
    if SMA(low,2)[1] > SMA(low,5)[1] &&
    if SMA(high,6)[5] > SMA(high,2)[5]&&
    if SMA(low,2)[4] > SMA(low,4)[4]
    // enter Long 2 contracts

    Its saying when simple moving average low of 2 crosses over simple moving average low of 5 one bar ago; and, simple moving average high of 6 crosses over simple moving average high of 2 five bars ago, and, simple moving average low of 2 crosses over simple moving average low of 4 four bars ago. How is this written in NT8? Thanks so much.​

    #2
    Hello SteveReiza,

    Thank you for your post.

    Please see the Help Guide page for the SMA in NinjaTrader 8:
    https://ninjatrader.com/support/help...simple_sma.htm

    You can use the CrossAbove() and/or CrossBelow() methods:
    https://ninjatrader.com/support/help...crossabove.htm

    https://ninjatrader.com/support/help...crossbelow.htm


    For your first check:

    Code:
    if (CrossAbove(SMA(Low, 2), SMA(Low, 5), 1)
    This checks if an SMA calculated using the Low price with a period of 2 has crossed above an SMA calculated using the Low price with a period of 5 within the last bar (1 bar ago).

    You can use similar logic for the rest of your checks.

    For an example script, take a look at the SampleMACrossover included in NinjaTrader 8.

    Please let me know if you have any other questions.

    Comment


      #3
      Sweet, thanks!

      Comment


        #4
        for more than one, is the below correct?

        if (CrossAbove(SMA(low,5), SMA(low,9),1) && (CrossAbove(SMA(low,2), SMA(low,4),5) && (CrossAbove(SMA(high,6), SMA(high,2),4))))

        Comment


          #5
          Hello,

          I fixed the parentheses and so that it is checking if each of the 3 CrossAboves are true in your statement. Also, make sure to capitalize High and Low.

          Code:
          if (CrossAbove(SMA(Low,5), SMA(Low,9),1) && CrossAbove(SMA(Low,2), SMA(Low,4),5) && CrossAbove(SMA(High,6), SMA(High,2),4))

          High - https://ninjatrader.com/support/helpGuides/nt8/high.htm
          Low - https://ninjatrader.com/support/helpGuides/nt8/low.htm

          Please let me know if you have any other questions.

          Comment


            #6

            Alright, thanks for the reminder. Rad, thank you!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            44 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X