Attachments forums

List of attachments posted on this forum.


All files on forums: 135975

Re: Coding Help

GERVASE, Mon Jun 19, 2017 8:13 pm

GERVASE wrote: Mon Jun 19, 2017 10:50 am Hi, mladen
May I check with you about the array indexing direction of user defined function, from the indicator StepMA pdf nmc 3.1416 + arrows.mq4, there is iStepMa user defined function with 2 dimensional array workStep[r][_smax], workStep[r][_smin], May I know if the array workStep indexing is timeseries or not?
Thanks!
double workStep[][3];
#define _smin 0
#define _smax 1
#define _trend 2

double iStepMa(double sensitivity, double stepSize, double stepMulti, double phigh, double plow, double pprice, int r)
{
if (ArrayRange(workStep,0)!=Bars) ArrayResize(workStep,Bars);
if (sensitivity == 0) sensitivity = 0.0001; r = Bars-r-1;
if (stepSize == 0) stepSize = 0.0001;
double result;
double size = sensitivity*stepSize;

//
//
//
//
//

if (r==0)
{
workStep[r][_smax] = phigh+2.0*size*stepMulti;
workStep[r][_smin] = plow -2.0*size*stepMulti;
workStep[r][_trend] = 1;
return(pprice);
}

//
//
//
//
//

workStep[r][_smax] = phigh+2.0*size*stepMulti;
workStep[r][_smin] = plow -2.0*size*stepMulti;
workStep[r][_trend] = workStep[r-1][_trend];
if (pprice>workStep[r-1][_smax]) workStep[r][_trend] = 1;
if (pprice<workStep[r-1][_smin]) workStep[r][_trend] = -1;
if (workStep[r][_trend] == 1) { if (workStep[r][_smin] < workStep[r-1][_smin]) workStep[r][_smin]=workStep[r-1][_smin]; result = workStep[r][_smin]+size*stepMulti; }
if (workStep[r][_trend] == -1) { if (workStep[r][_smax] > workStep[r-1][_smax]) workStep[r][_smax]=workStep[r-1][_smax]; result = workStep[r][_smax]-size*stepMulti; }
trend[Bars-r-1] = workStep[r][_trend];

return(result);
}
Hi, Mladen
Attached the file, please help, I have use the ArrayGetSeries function to check the workStep array, result shows it is not timeseries, not I am not the result is true or not. it make me quite confuse, please correct me!

Thanks!

regards
gervase
All files in topic