bool Stochastic () {
double Sig_Buy = zoneBUY;
double Sig_Sell = zoneSELL;
bool Exit_UrBuy = TRUE;
bool Exit_UrSell = TRUE;
double sM0,sM1,sS0, sS1;
bool Bar_BuyCross = FALSE;
bool Bar_SellCross = FALSE;
int bar_b, bar_s;
sM0 = iStochastic(NULL,timeframe,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_MAIN,1);
sM1 = iStochastic(NULL,timeframe,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_MAIN,2);
sS0 = iStochastic(NULL,timeframe,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_SIGNAL,1);
sS0 = iStochastic(NULL,timeframe,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_SIGNAL,2);
bool CrossBuy = (sS0<Sig_Buy && sM0<Sig_Buy && sM1<sS1 && sM0>=sS0);
bool CrossSell = (sS0>Sig_Sell && sM0>Sig_Sell && sM1>sS1 && sM0<=sS0);
if (UseExitUr) {
if (sM0 >Sig_Buy && sM1 <= Sig_Buy) Exit_UrBuy = TRUE;
else Exit_UrBuy = FALSE;
if (sM0 <Sig_Sell && sM1 >= Sig_Sell) Exit_UrSell = TRUE;
else Exit_UrSell = FALSE;
}
if (CrossBuy) { TimeCrossB = iOpen( NULL, 0, 1); }
for (int cnt = 1 ; cnt < Finder ; cnt++) {
bar_b = iBarShift(NULL, 0, TimeCrossB, cnt);
if (bar_b > 0) Bar_BuyCross = TRUE;
}
if (Bar_BuyCross && Exit_UrBuy) {
Li_24 = TRUE;
TimeCrossB = -1;
}
if (CrossSell) {TimeCrossS = iOpen( NULL, 0, 1);}
for (int cnm = 1 ; cnm < Finder ; cnm++) {
bar_s = iBarShift(NULL, 0, TimeCrossS, cnm);
if (bar_s > 0) Bar_SellCross = TRUE;
}
if (Bar_SellCross && Exit_UrSell) {
TimeCrossS = -1;
Li_28 = TRUE;
}
return(false);
}