void OnTick()
{
double Bid=SymbolInfoDouble(NULL,SYMBOL_BID);
double Ask=SymbolInfoDouble(NULL,SYMBOL_ASK);
double pr=0,sl=0,tp=0;
if(Mode)
ModeOOP();
if(ObjectGetInteger(0,"d",OBJPROP_STATE)==1)
{
DelOrder();
ObjectSetInteger(0,"d",OBJPROP_STATE,false);
}
if(ObjectGetInteger(0,"b",OBJPROP_STATE)==1)
{
pr=NormalizeDouble(Bid+Delta*_Point,_Digits);
if(StopLoss>0)
sl=NormalizeDouble(pr-StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(pr+TakeProfit*_Point,_Digits);
trade.BuyStop(Lots,pr,NULL,sl,tp,ORDER_TIME_SPECIFIED,TimeCurrent()+3600*Expiration,Comm);
ObjectSetInteger(0,"b",OBJPROP_STATE,false);
}
if(ObjectGetInteger(0,"s",OBJPROP_STATE)==1)
{
pr=NormalizeDouble(Bid-Delta*_Point,_Digits);
if(StopLoss>0)
sl=NormalizeDouble(pr+StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(pr-TakeProfit*_Point,_Digits);
trade.SellStop(Lots,pr,NULL,sl,tp,ORDER_TIME_DAY,TimeCurrent()+3600*Expiration,Comm);
ObjectSetInteger(0,"s",OBJPROP_STATE,false);
}
if(ObjectGetInteger(0,"cl",OBJPROP_STATE)==1)
{
CloseAll();
ObjectSetInteger(0,"cl",OBJPROP_STATE,false);
}
if(ObjectGetInteger(0,"by",OBJPROP_STATE)==1)
{
pr=NormalizeDouble(Ask,_Digits);
if(StopLoss>0)
sl=NormalizeDouble(pr-StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(pr+TakeProfit*_Point,_Digits);
trade.Buy(Lots,NULL,pr,sl,tp,Comm);
ObjectSetInteger(0,"by",OBJPROP_STATE,false);
}
if(ObjectGetInteger(0,"se",OBJPROP_STATE)==1)
{
pr=NormalizeDouble(Bid,_Digits);
if(StopLoss>0)
sl=NormalizeDouble(pr+StopLoss*_Point,_Digits);
if(TakeProfit>0)
tp=NormalizeDouble(pr-TakeProfit*_Point,_Digits);
trade.Sell(Lots,NULL,pr,sl,tp,Comm);
ObjectSetInteger(0,"se",OBJPROP_STATE,false);
}
}
На М30 и ниже ошибка присутствует.
Андрей, использую на H1 и выше. Если не опускаться ниже часовика получится сделать советника?
OSS5