Nicolas

Stair step moving average

Category: Indicators By: Nicolas Created: October 14, 2015, 12:28 PM
October 14, 2015, 12:28 PM
Indicators
1 Comment
Stair step moving average

Easy reading of moving average price action without annoying moving average whipsaws due of volatility, this indicator simply draws “stair step” within defined point/pip treshold value (Step).

As an example, this indicator only make use of SMA and could be easily adapt by anyone 🙂

There are different approach to trade this indi : other moving average crossover or simple price breakout of the line, use it as you would, enjoy.

//parameters :
// Step = 0.0010 forex 10 pips, adapt to item you are trading
// MAperiod = 20

once ssMA = close
MA = average[MAperiod](close)

if(MA > ssMA + Step) THEN
   ssMA = MA
ELSIF (MA < ssMA - Step) THEN
   ssMA = MA
ELSE
   ssMA = ssMA
ENDIF

RETURN ssMA

 

Download
Filename: Stair-step-moving-average.itf
Downloads: 143
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Petrus
10 years ago
#

Hi Nicolas.
I found this indicator very interesting and wanted to code it in form of histogram, where I could easily see the changes of the steps, but unfortunately it does not work correctly.
There are missing bars and bars that leftovers. I wanted to download an image, but I get always an HTTP error if I try it.
Could you please tell me where is the error on the code?

The code is:

//***Stair step Moving Average
//parameters :
Step = 10// 0.0010 forex 10 pips, adapt to item you are trading
MAperiod = 7

once ssMA = close
MA = average[MAperiod](close)

IF(MA > ssMA+Step) THEN
ssMA = MA
ELSIF (MA < ssMA-Step) THEN
ssMA = MA
ELSE
ssMA = ssMA
ENDIF

IF ssMA>ssMA[1] THEN
k=1
ELSIF ssMA<ssMA[1] THEN
k=-1
ELSE
k=0
ENDIF

RETURN k AS "Signal", 0 AS "Zero"

ProRealCode ProRealCode
Loading...