julesrulesny![]() Legend ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 498 Joined: 8/28/2009 Location: NYC ![]() | Hi, For years I have adapted zScore and zScoreMA into my Trading. Quite successfully. its very adaptable to all sorts of other indicators. Since the zScoreMA in a pane, as you can see in attachment, more or less moves with price (depending on the parameters of course).. I have been trying to figure out how to Code this so it can become an indicator used in the chart and NOT the pane... As I have additional motivations, creating a zScoreMA Bands..which I should be able to do.. What I can't do, the most important part is try and find a way to calculate this so it Plots in the chart... Any suggestions? If this is even possible?? Thanks, Marc Traditional zScore ----- #Indicator '********************************************************************** '* Z-Score Indicator '* by Jeremy Williams '* February 21,2006 '* '* Adapted from Technical Analysis of Stocks and Commodities '* February 2003 '* '* Summary: '* '* This indicator measures the normalized distance from the '* N period Moving Average using the statistical formula for Z-value. '* For more information see "Z-Score Indicator" in the '* February 2003 edition of Technical Analysis of Stocks and '* Commodities. '* '* Parameters: '* '* N= Specifies the number of Periods used for the Average and '* Standard Deviation calculations used to determine the '* Z-Score. '* '******************************************************************** #Indicator #Param "N",20 Dim myAverage As Single Dim mySD As Single Dim Value As Single Dim OutValue As Single ' Value statement can be changed to other data series. For example, ' to calculate the Z-Score Indicator of the RSI use: ' Value = RSI(Periods) Value = C myAverage = Average(Value,N) ' Calculate the Average and Standard Deviation mySD = STD(Value,N) OutValue = Value - myAverage ' Calculate the Z-Score using the formula: OutValue = OutValue / mySD ' Z = ( Value - Average ) / Standard Deviation If Bar < N then ' At Initialization set OutValue to 0 until OutValue = 0 ' Standard Deviation is not zero. End If Plot("Z-Score",OutValue) ' Plot the Z-score and the 1-Std. Dev. Band PlotLabel(-1) PlotLabel(1) Return OutValue ' Return the Z-value A rather simple, easy Moving Average of the zScore --- #Indicator #Param "periods",3 Dim ZS As Single Dim zsMA As Single zs = zscore(periods) zsMA = SMA(zs,periods) plot("zsMA", zsMA) return zsMA Also, a while back I think it was Mel who coded this one for me.. Another MA of zS. #Indicator #param "Zlength", 4 #param "maPeriod",6 #param "buylevel",-1.6 #param "shortLevel", 1.6 dim zs, theMA as single if bar>(Zlength+maPeriod) then zs = zScoreInd(Zlength,buyLevel,shortLevel) theMA = sma(zs,maPeriod) plot("zMA",theMA) plot("buy",buyLevel,black) plot("sell",shortLevel,black) end if Return theMA ' Return the value calculated by the indicator [Edited by julesrulesny on 11/24/2014 11:40 AM] |