Благодарю Вас уважаемый !!! (Все ошибаются
) Подскажите пожалйуста как правильно вставить код в советник?
//--------------------------------------------------------------------*/
extern int KPeriod = 6;
extern int DPeriod = 3;
extern int Slowing = 5;
extern int LevelSell = 75;
extern int LevelBuy = 25;
extern int Stoploss = 10; //стоплосс
extern int Takeprofit = 15; //тейкпрофит
extern int TrailingStop = 0; //трейлингстоп, если 0, то нет трейлинга
extern double Lot = 0.10; //лот
extern int slippage = 1; // проскальзывание
extern int Magic = 2222;
//--------------------------------------------------------------------
double STOPLEVEL;
//-------------------------------------------------------------------
void OnTick()
{
if (!IsTradeAllowed())
{
return;
}
STOPLEVEL=MarketInfo(Symbol(),MODE_STOPLEVEL);
double OSL,OTP,OOP,StLo=0,SL=0,TP=0;
int i,b=0,s=0,tip;
for (i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if (OrderSymbol()==Symbol() && Magic==OrderMagicNumber())
{
tip = OrderType();
OSL = NormalizeDouble(OrderStopLoss(),Digits);
OTP = NormalizeDouble(OrderTakeProfit(),Digits);
OOP = NormalizeDouble(OrderOpenPrice(),Digits);
SL=OSL;TP=OTP;
if (tip==OP_BUY)
{
b++;
if (OSL==0 && Stoploss>=STOPLEVEL && Stoploss!=0)
{
SL = NormalizeDouble(OOP - Stoploss * Point,Digits);
}
if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)
{
TP = NormalizeDouble(OOP + Takeprofit * Point,Digits);
}
if (TrailingStop>=STOPLEVEL && TrailingStop!=0)
{
StLo = NormalizeDouble(Bid - TrailingStop*Point,Digits);
if (StLo >= OOP && StLo > OSL) SL = StLo;
}
if (SL != OSL || TP != OTP)
{
if (!OrderModify(OrderTicket(),OOP,SL,TP,0,clrNONE)) Print("Error OrderModify <<",(GetLastError()),">> ");
}
}
if (tip==OP_SELL)
{
s++;
if (OSL==0 && Stoploss>=STOPLEVEL && Stoploss!=0)
{
SL = NormalizeDouble(OOP + Stoploss * Point,Digits);
}
if (OTP==0 && Takeprofit>=STOPLEVEL && Takeprofit!=0)
{
TP = NormalizeDouble(OOP - Takeprofit * Point,Digits);
}
if (TrailingStop>=STOPLEVEL && TrailingStop!=0)
{
StLo = NormalizeDouble(Ask + TrailingStop*Point,Digits);
if (StLo <= OOP && (StLo < OSL || OSL==0)) SL = StLo;
}
if (SL != OSL || TP != OTP)
{
if (!OrderModify(OrderTicket(),OOP,SL,TP,0,clrNONE)) Print("Error OrderModify <<",(GetLastError()),">> ");
}
}
}
}
}
//----------------------------------------------------------------
double Stoch0 = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_MAIN,0);
double Signl0 = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
double Stoch1 = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_MAIN,1);
double Signl1 = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,MODE_SMA,0,MODE_SIGNAL,1);
//-----------------------------------------------------------------------
if (Stoch0>Signl0 && Stoch1<Signl1 && Stoch0<LevelBuy)
{
if (b==0)
{
if (OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,0,0,NULL,Magic,0,clrNONE)==-1) Print("Ошибка открытия ордера <<",(GetLastError()),">> ");
}
}
if (Stoch0<Signl0 && Stoch1>Signl1 && Stoch0>LevelSell)
{
if (s==0)
{
if (OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,0,0,NULL,Magic,0,clrNONE)==-1) Print("Ошибка открытия ордера <<",(GetLastError()),">> ");
}
}
return;
}
//--------------------------------------------------------------------
Грызу "гранит" MQL :facepalm: