Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving Average Filter

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

    Moving Average Filter

    Good Evening I hope everyone is having a good weekend.

    I am sure that there is a very simple solution for this. I am attempting to filter my working strategy to only take a trade above or below a certain moving average. For an easy example, (not necessarily the same period moving average I am using), I want it to trade my strategy, but filtering to only take a long if we are above the 15 period SMA, and only take a short if the market is below the 15 period SMA. What combination of parameters must I use to make proper use of this moving average filter line. This seems like an easy solution but I am just not figuring it out. Thanks in advance for your help.

    #2
    Hi Superlite,
    We all started as Junior Members.
    The attached just uses the SMA filter. Add you other conditions and have fun.
    NT-Roland
    Attached Files

    Comment


      #3
      Hi NT-Roland,

      Thanks for the reply and for creating that for me. It seems as though that what you have created is not necessarily filtering, but rather being it's own strategy. The strategy is now using price crossing the SMA line as the entry and exit parameter into the trade rather than using my strategy as as the entry and exit. Do you have any other ideas we could try? Thanks.

      Comment


        #4
        Hello Superlite,
        You can simply add another condition to your existing set of conditions : Close[0] > SMA(15)[0] for long entry & Close[0] < SMA(15)[0] for short entry. Use Strategy Builder so you don't make a mistake. Hope it helps.
        Last edited by s.kinra; 10-17-2020, 11:08 PM.

        Comment


          #5
          Hello Superlite,

          If you have not already watched the Strategy Builder 301 training video I recommend this as a starting place.


          I am also including a link to a forum post with helpful information about getting started with NinjaScript.


          NT-Roland, thank you for your sample code and sample script.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            There is another handy little thing you can do in the strategy builder which is to take the moving average you like and compare it to where it was a certain number of bars ago. SMA(15)[20] > SMA(15)[0]

            In the above example its a great little filter that ensures the moving average itself is falling compared to the same moving average 20 bars ago. This can be in addition to your other filter above. The Ninjatrader staff can correct me if I am wrong.

            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