Download MetaTrader 5

how to get two highest or lowest point nearest of Indicator

To add comments, please log in or register
Jhonson
35
Jhonson  


int theBarh1,theBarh2;
double theHighest1=0,theHighest2=0;
double price_h1,price_h2;
int stoch_bar;
double stoch=iStochastic("EURUSDpro",PERIOD_M15,5,3,3,MODE_EMA,1,MODE_SIGNAL,0);
if(stoch<80)
{
for(int bar1 = 0; bar1 <= 40;bar1++)
{
double stoch1;
stoch1 = iStochastic("EURUSDpro",PERIOD_M15,5,3,3,MODE_EMA,1,MODE_SIGNAL,bar1);
if(stoch1>theHighest1)
{
theHighest1 = stoch1;
theBarh1 = bar1;
price_h1 = iHigh("EURUSDpro",PERIOD_M15,theBarh1);
}
if(stoch1<70){ stoch_bar = bar1;break;}
}
}

for(int bar2=stoch_bar;bar2<=(40-stoch_bar);bar2++)
{
double stoch2 = iStochastic("EURUSDpro",PERIOD_M15,5,3,3,MODE_EMA,1,MODE_SIGNAL,bar2);
if((stoch2>theHighest2)&&(stoch2>80))
{
theHighest2 = stoch2;
theBarh2 = bar2;
price_h2 = iHigh("EURUSDpro",PERIOD_M15,theBarh2);
}
if(stoch2<75)break;
}

i wite code,but it dosen't work help me

Ubzen
5390
Ubzen  

You need to repost your code ... it lost its formatting.

Are you looking for the highest price within 40 bars when stochastic is less than 80?

To add comments, please log in or register