GERVASE wrote: Sun Jun 11, 2017 11:07 pm
Dear code experts:
I saw the StepMA_v1.mq4 code, but i have concern about the the variable smin0,smax0,smin1,smax1, so the smax1 & smin1 are the previous bar value of smax0&smin0? and this code work? for my understanding, should write the code like: smin[shift], smin[shift+1].
Thanks!
int start()
{
int shift,trend;
double smin0,smax0,smin1,smax1;
for(shift=Bars-1;shift>=0;shift--)
{
if (HighLow>0)
{
smax0=Low[shift]+2*StepSize*Point;
smin0=High[shift]-2*StepSize*Point;
if(Close[shift]>smax1) trend=1;
if(Close[shift]<smin1) trend=-1;
}
if (HighLow == 0)
{
smax0=Close[shift]+2*StepSize*Point;
smin0=Close[shift]-2*StepSize*Point;
if (Close[shift]>smax1) trend=1;
if (Close[shift]<smin1) trend=-1;
}
if(trend>0 && smin0<smin1) smin0=smin1;
if(trend<0 && smax0>smax1) smax0=smax1;
if (trend>0) LineBuffer[shift]=smin0+StepSize*Point;
if (trend<0) LineBuffer[shift]=smax0-StepSize*Point;
smin1=smin0;
smax1=smax0;