void OnTick()
{
st1();
Massiv();
Comment(arr[3].body,"+",arr[2].body,"+",arr[1].body);
}
void massiv()
{
arr1.lot = Lot;
arr1.risk = Risk;
arr1.loss = StopLoss*Point;
arr1.prof = TakeProfit*Point;
arr1.tral = Tral*Point;
arr1.disfriz = (int)MarketInfo(Symbol(),MODE_FREEZELEVEL);
arr1.profby = NormalizeDouble(Ask+TakeProfit*Point,Digits);
arr1.profsh = NormalizeDouble(Bid-TakeProfit*Point,Digits);
arr1.stopby = NormalizeDouble(Bid-StopLoss*Point,Digits);
arr1.stopsh = NormalizeDouble(Ask+StopLoss*Point,Digits);
arr1.profbymin = NormalizeDouble(Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,Digits);
arr1.profshmin = NormalizeDouble(Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,Digits);
arr1.stopbymin = NormalizeDouble(Bid-MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,Digits);
arr1.stopshmin = NormalizeDouble(Ask+MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,Digits);
arr1.swl = NormalizeDouble(MarketInfo(Symbol(),18)*Point,Digits);
arr1.sws = NormalizeDouble(MarketInfo(Symbol(),19)*Point,Digits);
arr1.mag = Magic;
}
void Massiv()
{
//---Заполнение массивов инидкаторов
for(i=0; i<ArraySize(arr); i++)
{
arr[i].AC=iAC(Symbol(),PERIOD_CURRENT,i);
arr[i].AD=iAD(Symbol(),PERIOD_CURRENT,i);
arr[i].ADXMn=iADX(Symbol(),PERIOD_CURRENT,31,PRICE_CLOSE,MODE_MAIN,i);
arr[i].ADXDP=iADX(Symbol(),PERIOD_CURRENT,31,PRICE_CLOSE,MODE_PLUSDI,i);
arr[i].ADXDM=iADX(Symbol(),PERIOD_CURRENT,31,PRICE_CLOSE,MODE_MINUSDI,i);
arr[i].AO=iAO(Symbol(),PERIOD_CURRENT,i);
arr[i].ATR=iATR(Symbol(),PERIOD_CURRENT,31,i);
arr[i].AligatorJA = iAlligator(Symbol(),PERIOD_CURRENT,31,8,15,5,7,3,MODE_LWMA,PRICE_CLOSE,MODE_GATORJAW,i);
arr[i].AligatorTE = iAlligator(Symbol(),PERIOD_CURRENT,31,8,15,5,7,3,MODE_LWMA,PRICE_CLOSE,MODE_GATORTEETH,i);
arr[i].AligatorLI = iAlligator(Symbol(),PERIOD_CURRENT,31,8,15,5,7,3,MODE_LWMA,PRICE_CLOSE,MODE_GATORLIPS,i);
arr[i].BEP = iBearsPower(Symbol(),PERIOD_CURRENT,31,PRICE_CLOSE,i);
arr[i].BUP = iBullsPower(Symbol(),PERIOD_CURRENT,31,PRICE_CLOSE,i);
arr[i].BNDM = iBands(Symbol(),PERIOD_CURRENT,31,2,0,PRICE_CLOSE,MODE_MAIN,i);
arr[i].BNDU = iBands(Symbol(),PERIOD_CURRENT,31,2,0,PRICE_CLOSE,MODE_UPPER,i);
arr[i].BNDL = iBands(Symbol(),PERIOD_CURRENT,31,2,0,PRICE_CLOSE,MODE_LOWER,i);
arr[i].BWM = iBWMFI(Symbol(),PERIOD_CURRENT,i);
arr[i].body = Open[i]-Close[i];
arr[i].CCL = iCCI(Symbol(),PERIOD_CURRENT,31,PRICE_CLOSE,i);
arr[i].close = Close[i];
arr[i].DM = iDeMarker(Symbol(),PERIOD_CURRENT,31,i);
}
}
//+------------------------------------------------------------------+
//| Пользовательские функции |
//+------------------------------------------------------------------+
bool f_IsNewBar()//новый бар
{
if(intBars != Bars)
{
intBars = Bars;
return(true);
}
return(false);
}
//+------------------------------------------------------------------+
bool Uhrtraid()//Торговля на определенном часе
{
bool trade = false;
if(Hour()== Uhr && Minute()==00 && Seconds()==00)
trade=true;
else
trade=false;
return(trade);
}
//+------------------------------------------------------------------+
int NumberBars()//Торговля на определеном баре
{
datetime Result = 0;
int number = 0;
for(int j = 0; j < OrdersTotal(); j++)
if(OrderSelect(i, SELECT_BY_POS))
if(OrderSymbol() == Symbol())
if(OrderOpenTime() > Result)
Result = OrderOpenTime();
if(iBarShift(_Symbol,PERIOD_CURRENT, Result,true)==5)
number=5;
else
number=-1;
return(number);
}
//+------------------------------------------------------------------+
void st1()//Стратегий таких много будет в одном советнике
{
bool dan = true;
massiv();
Massiv();
if(arr[3].body>0 && arr[2].body>0 && arr[1].body>0)
dan =true;//Покупки
else
if(arr[3].body<0 && arr[2].body<0 && arr[1].body<0)
dan=false;//Продажи
switch(Vremytorg)
{
case 0://На новом баре
if(dan==true && f_IsNewBar()==true)
ticketss=OrderSend(Symbol(),OP_BUY,arr1.lot,Ask,Slippage,0,0,"S1",arr1.mag,clrNONE);
if(dan==false && f_IsNewBar()==true)
ticketss=OrderSend(Symbol(),OP_SELL,arr1.lot,Bid,Slippage,0,0,"S1",arr1.mag,clrNONE);
break;
case 1://Только один ордер открывать
if(dan==true && OrdersTotal()==0)
ticketss=OrderSend(Symbol(),OP_BUY,arr1.lot,Ask,Slippage,0,0,"S1",arr1.mag,clrNONE);
if(dan==false && OrdersTotal()==0)
ticketss=OrderSend(Symbol(),OP_SELL,arr1.lot,Bid,Slippage,0,0,"S1",arr1.mag,clrNONE);
break;
case 2://На определеннои баре
if(dan==true && NumberBars()==Uhr)
ticketss=OrderSend(Symbol(),OP_BUY,arr1.lot,Ask,Slippage,0,0,"S1",arr1.mag,clrNONE);
if(dan==false && NumberBars()==Uhr)
ticketss=OrderSend(Symbol(),OP_SELL,arr1.lot,Bid,Slippage,0,0,"S1",arr1.mag,clrNONE);
break;
case 3://В определенный час
if(dan==true && Uhrtraid()==true)
ticketss=OrderSend(Symbol(),OP_BUY,arr1.lot,Ask,Slippage,0,0,"S1",arr1.mag,clrNONE);
if(dan==false && Uhrtraid()==true)
ticketss=OrderSend(Symbol(),OP_SELL,arr1.lot,Bid,Slippage,0,0,"S1",arr1.mag,clrNONE);
break;
case 4://В положительный своп
if(dan==true && arr1.swl>0)
ticketss=OrderSend(Symbol(),OP_BUY,arr1.lot,Ask,Slippage,0,0,"S1",arr1.mag,clrNONE);
if(dan==false && arr1.sws>0)
ticketss=OrderSend(Symbol(),OP_SELL,arr1.lot,Bid,Slippage,0,0,"S1",arr1.mag,clrNONE);
break;
case 5://Как есть торговать
if(dan==true)
ticketss=OrderSend(Symbol(),OP_BUY,arr1.lot,Ask,Slippage,0,0,"S1",arr1.mag,clrNONE);
if(dan==false)
ticketss=OrderSend(Symbol(),OP_SELL,arr1.lot,Bid,Slippage,0,0,"S1",arr1.mag,clrNONE);
break;
}
}