Utrecht+Utrecht/ The netherlands
Posts: 11 since Apr 2015
Thanks Given: 7
Thanks Received: 12
|
I do have a more simplified Stepup moving average or Block moving average code in easylanguage, this has about the same output. Maybe this one is easier to convert for Sierra Charts?
The code:
{=== StepUp Moving Average OR Block Moving Average =============}
Inputs: SU_ATR_Length ( 2000 ),
SU_ATR_BoxMultiplyer_1 ( 8 ),
SU_ATR_BoxMultiplyer_2 ( 13 );
Vars: SU_DIR1(0), SU_WorkBoxHalf1(0), SU_Midl1(0), SU_Bot1(0), SU_Top1(0),
SU_DIR2(0), SU_WorkBoxHalf2(0), SU_Midl2(0), SU_Bot2(0), SU_Top2(0) ;
SU_WorkBoxHalf1 = ( SU_ATR_BoxMultiplyer_1 * AvgTrueRange( SU_ATR_Length ) * 0.5 ) ;
If H > SU_Top1 then begin
SU_DIR1 = 1 ;
SU_Top1 = H ;
SU_Midl1 = SU_Top1 - SU_WorkBoxHalf1 ;
SU_Bot1 = SU_Top1 - ( 2 * SU_WorkBoxHalf1 ) ;
End else
If L < SU_Bot1 then begin
SU_DIR1 = -1 ;
SU_Bot1 = L ;
SU_Midl1 = SU_Bot1 + SU_WorkBoxHalf1 ;
SU_Top1 = SU_Bot1 + ( 2 * SU_WorkBoxHalf1 ) ;
end ;
SU_WorkBoxHalf2 = ( SU_ATR_BoxMultiplyer_2 * AvgTrueRange( SU_ATR_Length ) * 0.5 ) ;
If H > SU_Top2 then begin
SU_DIR2 = 1 ;
SU_Top2 = H ;
SU_Midl2 = SU_Top2 - SU_WorkBoxHalf2 ;
SU_Bot2 = SU_Top2 - ( 2 * SU_WorkBoxHalf2 ) ;
End else
If L < SU_Bot2 then begin
SU_DIR2 = -1 ;
SU_Bot2 = L ;
SU_Midl2 = SU_Bot2 + SU_WorkBoxHalf2 ;
SU_Top2 = SU_Bot2 + ( 2 * SU_WorkBoxHalf2 ) ;
end ;
{ ================ Print ======================================}
vars: SU_mid_C1(0), SU_mid_C2(0);
If SU_DIR1 = 1 then SU_mid_C1 = cyan else SU_mid_C1 = magenta ;
plot1 ( SU_Midl1, " SU_Midl1 " , SU_mid_C1 ) ;
If SU_DIR2 = 1 then SU_mid_C2 = cyan else SU_mid_C2 = magenta ;
plot2 ( SU_Midl2, " SU_Midl2 ", SU_mid_C2 ) ;
|