...
if(_eur && _usd)
{
string symb = "EURUSD";
int COR = coralCL(symb);
double atr = ATR(symb);
int DaHL = Daily_High_Low(symb);
int ML = Max_lenth(symb);
int DfMA = Distance_from_MA(symb);
int spread = MarketInfo(symb,MODE_SPREAD);
double MA = iMA( symb, TFMA, periodMA, ma_shift, ma_method, applied_price, 0);
print = print+"\n "+symb+" |AVG(min"+Enter+")="+DoubleToStr(AVG_eur-AVG_usd,0)+" |ATR(min"+ATRLevel+")="+DoubleToStr(atr,0)+" |Price-MA(min"+Min_Distance_from_MA+" (if Down+"+spread+"))="+DoubleToStr((iClose(symb,0,0)-MA)*10000,0)
+" |CandleLenth(max"+Max_lenth_of_Candle+")="+DoubleToStr((iHigh(symb,0,0)-iLow(symb,0,0))*10000,0)+" |DailyHighLow(min"+Min_D_High_Low+")="+DoubleToStr((iHigh(symb,PERIOD_D1,0)-iLow(symb,PERIOD_D1,0))*10000,0);
countOpenPosition(symb, MAGIC);
if(GO && (atr>=ATRLevel || !UseATR) && CheckAVGfresh(1, AVG_eur, AVG_usd))
{
if((AVG_eur-AVG_usd)>=Enter && DaHL>0 && ML>0 && DfMA>0 && buy==0)
Buy(symb, Lot, SL, TP, symb+Comment_, slip, MAGIC, MaxAttempts, Blue);
if((AVG_usd-AVG_eur)>=Enter && DaHL>0 && ML>0 && DfMA<0 && sell==0)
Sell(symb, Lot, SL, TP, symb+Comment_, slip, MAGIC, MaxAttempts, Red);
}
if((UseMAexit && COR<0) && buy>0) CloseAll(symb, OP_BUY, MAGIC);
if((UseMAexit && COR>0) && sell>0) CloseAll(symb, OP_SELL, MAGIC);
}
...
bool CheckAVGfresh(int i, double AVG_1, double AVG_2)
{
if(!UseFreshSignal) return(true);
if(avg_[i] == 0 && ((AVG_1-AVG_2)>=Enter && buy==0)) {avg_[i] = MathAbs(AVG_1 - AVG_2); return(true);}
if(avg_[i] == 0 && ((AVG_2-AVG_1)>=Enter && sell==0)) {avg_[i] = MathAbs(AVG_1 - AVG_2); return(true);}
if(avg_[i] > 0 && (AVG_1-AVG_2)>0 && (AVG_1-AVG_2)<(Enter-freshlevel) && buy==0) {avg_[i] = 0; return(true);}
if(avg_[i] > 0 && (AVG_2-AVG_1)>0 && (AVG_2-AVG_1)<(Enter-freshlevel) && sell==0) {avg_[i] = 0; return(true);}
// if(avg_[i] == 0) return(true);
return(false);
}
///////////////////////////////////////////////////////////////////////////////////////////////
double ATR(string symb)
{
if(!UseATR) return(0);
int li_8;
double ld_ret_0 = 0;
if (StringFind(symb, "JPY", 0) != -1) li_8 = 100;
else li_8 = 10000;
ld_ret_0 = MathCeil(li_8 * 3 * iATR(symb, TFATR, ATRPeriod, 0));
return (ld_ret_0);
// return(iATR(symb, TFATR, ATRPeriod, 1));
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+coralCL
int coralCL(string symb)
{
if(!UseMAexit) return(0);
double cor1 = iMA( symb, TFMA, periodMA, ma_shift, ma_method, applied_price, 0);
int spread = MarketInfo(symb,MODE_SPREAD);
double point = MarketInfo(symb,MODE_POINT);
if(iClose(symb,0,0)+spread*point<cor1) return(-1);
if(iClose(symb,0,0)>cor1) return (1);
return(0);
}
//////////////////////////////////////////////////////////////////
int Daily_High_Low(string symb)
{
double point = MarketInfo(symb,MODE_POINT);
if(MarketInfo(symb, MODE_DIGITS) == 3 || MarketInfo(symb, MODE_DIGITS) == 5)
point = MarketInfo(symb, MODE_POINT)*10;
if (iHigh(symb,PERIOD_D1,0)-iLow(symb,PERIOD_D1,0)>=Min_D_High_Low*point) return(1);
return(0);
}
/////////////////////////////////////////////////////////////////////
int Daily_High_Low_JPY(string symb)
{
double point = MarketInfo(symb,MODE_POINT);
if(MarketInfo(symb, MODE_DIGITS) == 3 || MarketInfo(symb, MODE_DIGITS) == 5)
point = MarketInfo(symb, MODE_POINT)*10;
if (iHigh(symb,PERIOD_D1,0)-iLow(symb,PERIOD_D1,0)>=Min_D_High_Low_JPY*point) return(1);
return(0);
}
/////////////////////////////////////////////////////////////////////
int Max_lenth(string symb)
{
double point = MarketInfo(symb,MODE_POINT);
if(MarketInfo(symb, MODE_DIGITS) == 3 || MarketInfo(symb, MODE_DIGITS) == 5)
point = MarketInfo(symb, MODE_POINT)*10;
if (iHigh(symb,0,0)-iLow(symb,0,0)<=Max_lenth_of_Candle*point) return(1);
return(0);
}
/////////////////////////////////////////////////////////////////////
int Distance_from_MA(string symb)
{
double MA = iMA( symb, TFMA, periodMA, ma_shift, ma_method, applied_price, 0);
int spread = MarketInfo(symb,MODE_SPREAD);
double point = MarketInfo(symb,MODE_POINT);
if(MarketInfo(symb, MODE_DIGITS) == 3 || MarketInfo(symb, MODE_DIGITS) == 5)
point = MarketInfo(symb, MODE_POINT)*10;
if(iClose(symb,0,0)+(spread*point)+(Min_Distance_from_MA*point)<=MA) return(-1);
if(iClose(symb,0,0)-(Min_Distance_from_MA*point)>=MA) return (1);
return(0);
}