To visualize the difference between the "Traditional" method and the "Jorgen" 
method when calculating MA run the following script on let's say 1min chart 
(higher timeframe set to 15min by default):

TF = Param(" Higher Timeframe",15,2,60,1);
Period = Param("MA Period",10,2,50,1);

Jorgen_MA = Null;

TimeFrameSet(in1Minute * TF);
BI_TF = BarIndex();     
Close_TF = Close;
MA_TF = MA(Close_TF,Period);
Sum_TF = Sum(Close_TF,Period - 1);

TimeFrameRestore();
CLOSE_TF_Base = TimeFrameExpand(Close_TF,in1Minute * TF);
BI_TF_Base = TimeFrameExpand(BI_TF,in1Minute * TF);
TF_Bar = IIf(BI_TF_Base != Ref(BI_TF_Base,-1),1,0);

MA_TF_Base = TimeFrameExpand(MA_TF,in1Minute * TF);
Sum_TF_Base = TimeFrameExpand(Sum_TF,in1Minute * TF);

Jorgen_MA = (Sum_TF_Base + Close) / Period;

Plot(CLOSE_TF_Base,"TF", colorRed);
Plot(MA_TF_Base,"MA_TF", colorYellow);
Plot(Jorgen_MA,"JMA", colorBrightGreen);

Height = Param("TF Bar Height as % of Y axis",10, 2, 100, 1) ;
Plot(TF_Bar,"",colorBlue,styleOwnScale|styleHistogram,Height);

AF 


Reply via email to