This indicator is a standardized MACD, it gives values also knows as Z-Score which represent the deviation of a value compared to an average of its deviation over a greater period.
By default the study period is set to 2000. So the indicator will draw the current MACD normalized accordingly to what happen to the MACD in this past 2000 bars. The Z-Score is drawn from -3 to +3 deviation from the 0 mean. So adapt these lines to the period and volatility of the instrument you are studying.
This code could be adapted to any other indicator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
FastLength = 12 SlowLength = 26 MACDLength = 9 SamplePeriod = 2000 // MACD ValueSample = ExponentialAverage[FastLength](close) - ExponentialAverage[SlowLength](close) AvgSample = ExponentialAverage[MACDLength](ValueSample) DiffSample = ValueSample - AvgSample //These are the Sample Mean and Sample Standard Deviations of //the 3 output values of the MACD function SMValue = Average[SamplePeriod](ValueSample) SSTDEVValue = std[SamplePeriod](ValueSample) SMAvg = Average[SamplePeriod](AvgSample) SSTDEVAvg= std[SamplePeriod](AvgSample) SMDiff = Average[SamplePeriod](DiffSample) SSTDEVDiff=std[SamplePeriod](DiffSample) //Now use the standard TOS MACD to figure the current MACD to //be standardized (converted to Z-score) later Value = ExponentialAverage[fastLength](close) - ExponentialAverage[slowLength](close) Avg = ExponentialAverage[MACDLength](Value) Diff = Value-Avg //Standardize the 3 outputs from the TOS MACD function StandValue = (Value - SMValue)/SSTDEVValue StandAvg=(Avg-SMAvg)/SSTDEVAvg StandDiff=(Diff-SMDiff)/SSTDEVDiff RETURN StandValue as "Signal-Z", StandAvg as "Average Signal-Z", StandDiff as "MACD-Z", 0 as "0", 1, -1, 2, -2, 3, -3 |
code adapted from Louis Sparks
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Did anyone get an error with lines 25 and 26?