Announcement

Collapse
No announcement yet.

Help: Slope of moving average as filter

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

  • Help: Slope of moving average as filter

    Hello!

    I have this RSI trading system which I want to combine with an additional trading signal. This signal should be a simple 200-period moving average as a filter. The criterion is the slope of the 200-period moving average, either rising or falling (current value of ma minus prior value of ma divided by prior value times 100). For example a buy signal should be created if RSI is below 30 (oversold) AND the slope of 200-period moving average is rising.

    I would be really happy if someone could write an EFS-study which has the slope filter in it so that I can adapt it to my RSI study.

    Thanks ahead!

    Regards,

    Simontrader

  • #2
    Simontrader
    The attached efs may do what you want or at least provide a starting point.
    It calculates and compares the slope of the 200 SMA on each bar with that of the prior bar and if the slope is rising and the RSI is below 30 it paints the background in lime.
    Note that the slope may be rising even while the MA is still moving down.
    Alex

    Attached Files

    Comment


    • #3
      @Alexis: Wow, thanks!

      Hello
      Attached Files

      Comment


      • #4
        oops

        @Alexis: Thanks very much for your quick reply and the efs code you have programed!

        Below I accidently attached a chart without text. So here is my text:

        Visually you cannot see that the current moving average is higher than the prior moving average. On the chart it looks like the slope is falling, just as you wrote in your message.

        So I will try to modify the code in a way, that "what you see is what you get", I mean I will try to make the moving average which 'looks rising' also the trigger of the filter signal. I think I could achieve that by not comparing the current and the prior period moving average, but maybe the current and the prior -10 period. Oh, I hope I didn't explain too korky.

        What do you think ?


        Greetings

        Simontrader

        Comment


        • #5
          Simontrader
          That is partly the problem with defining a rising/falling slope based only on one bar difference.
          You could increase the amount of the lookback and to do that you would change the bar index values in the definition of the vValue2 variable.
          For example if you wanted to compare the current slope to that of 10 bars ago you would change the definition to
          var vValue2 = ((vMA.getValue(MAStudy.MA,-10)-vMA.getValue(MAStudy.MA,-11))/vMA.getValue(MAStudy.MA,-11))*100;
          This may return results that are more in line with the visuals you are expecting.
          Hope this helps
          Alex

          Comment

          Working...
          X