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

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.
    Gaby V.NinjaTrader Customer Service

    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.
          Gaby V.NinjaTrader Customer Service

          Comment


            #6

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,403 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by Shai Samuel, 07-02-2022, 02:46 PM
            4 responses
            94 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by DJ888, Yesterday, 10:57 PM
            0 responses
            6 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Yesterday, 09:29 PM
            0 responses
            8 views
            0 likes
            Last Post Belfortbucks  
            Working...
            X