failed [Invalid S/L or T/P]

 
I have a problem with the wrong sl and tp tester everything is working properly

 

 int OrdSend(string _symbol, int _cmd, double _volume, double _price, int _slippage, double _stoploss, double _takeprofit, string _comment="", int _magic=0, datetime _expiration=0, color _arrow_color=CLR_NONE) {

//Send order with retry capabilities and log

int _stoplevel=MarketInfo(_symbol,MODE_STOPLEVEL);

double _priceop=0;

int ticket,err,tries;

tries = 0;

switch (_cmd) {

case OP_BUY:

while (tries < NumberOfTries) {

RefreshRates();

if (ECNBroker)

{

  ticket = OrderSend(_symbol,OP_BUY,_volume,Ask,_slippage,0,0,_comment,_magic,_expiration,_arrow_color);

  if (ticket>0)

     dummyResult = OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),0,CLR_NONE);

         }

         else ticket = OrderSend(_symbol,OP_BUY,_volume,Ask,_slippage,NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),_comment,_magic,_expiration,_arrow_color);

if(ticket<=0) {

Write("Error Occured : "+ErrorDescription(GetLastError()));

Write(Symbol()+" Buy @ "+Ask+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

tries++;

} else {

tries = NumberOfTries;

Write("Order opened : "+Symbol()+" Buy @ "+Ask+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

}

Sleep(RetryTime*1000);

}

err=ticket;

break;



case OP_SELL:

while (tries < NumberOfTries) {

RefreshRates();

if (ECNBroker)

{

  ticket = OrderSend(_symbol,OP_SELL,_volume,Bid,_slippage,0,0,_comment,_magic,_expiration,_arrow_color);

  if (ticket>0)

     dummyResult = OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),0,CLR_NONE);

         }

         else ticket = OrderSend(_symbol,OP_SELL,_volume,Bid,_slippage,NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),_comment,_magic,_expiration,_arrow_color);

if(ticket<=0) {

Write("Error Occured : "+ErrorDescription(GetLastError()));

Write(Symbol()+" Sell @ "+Bid+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

tries++;

} else {

tries = NumberOfTries;

Write("Order opened : "+Symbol()+" Sell @ "+Bid+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

}

Sleep(RetryTime*1000);

}

err=ticket;

break;



case OP_BUYSTOP:

while (tries < NumberOfTries) {

RefreshRates();

if ((_price-Ask)<_stoplevel*Point) _priceop=Ask+_stoplevel*Point; else _priceop=_price;

if (ECNBroker)

{

  ticket = OrderSend(_symbol,OP_BUYSTOP,_volume,NormalizeDouble(_priceop,Digits),_slippage,NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),_comment,_magic,_expiration,_arrow_color);

   //ticket1=OrderSend(Symbol(),OP_BUYSTOP,lot,Ask+Point*pip,3,Ask-Point*sl,Ask+Point*tp,"Pending order Buystop ",magic,0,Blue); 

  

  if (ticket>0)

     dummyResult = OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),0,CLR_NONE);

         }

         else ticket = OrderSend(_symbol,OP_BUYSTOP,_volume,NormalizeDouble(_priceop,Digits),_slippage,NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),_comment,_magic,_expiration,_arrow_color);

if(ticket<=0) {

Write("Error Occured : "+ErrorDescription(GetLastError()));

Write(Symbol()+" Buy Stop @ "+_price+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

tries++;

} else {

tries = NumberOfTries;

Write("Order opened : "+Symbol()+" Buy Stop@ "+_priceop+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

}

Sleep(RetryTime*1000);

}

err=ticket;

break;





case OP_SELLSTOP:

while (tries < NumberOfTries) {

RefreshRates();

if ((Bid-_price)<_stoplevel*Point) _priceop=Bid-_stoplevel*Point; else _priceop=_price;

         if (ECNBroker)

{

  ticket = OrderSend(_symbol,OP_SELLSTOP,_volume,NormalizeDouble(_priceop,Digits),_slippage,0,0,_comment,_magic,_expiration,_arrow_color);

  if (ticket>0)

     dummyResult = OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),0,CLR_NONE);

         }

         else ticket = OrderSend(_symbol,OP_SELLSTOP,_volume,NormalizeDouble(_priceop,Digits),_slippage,NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),_comment,_magic,_expiration,_arrow_color);

if(ticket<=0) {

Write("Error Occured : "+ErrorDescription(GetLastError()));

Write(Symbol()+" Sell Stop @ "+_priceop+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

tries++;

} else {

tries = NumberOfTries;

Write("Order opened : "+Symbol()+" Sell Stop @ "+_priceop+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

}

Sleep(RetryTime*1000);

}

err=ticket;

break;





case OP_BUYLIMIT:

while (tries < NumberOfTries) {

RefreshRates();

if ((Ask-_price)<_stoplevel*Point) _priceop=Ask-_stoplevel*Point; else _priceop=_price;

         if (ECNBroker)

{

  ticket = OrderSend(_symbol,OP_BUYLIMIT,_volume,NormalizeDouble(_priceop,Digits),_slippage,0,0,_comment,_magic,_expiration,_arrow_color);

  if (ticket>0)

     dummyResult = OrderModify(ticket,OrderOpenPrice(),NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),0,CLR_NONE);

         }

         else ticket = OrderSend(_symbol,OP_BUYLIMIT,_volume,NormalizeDouble(_priceop,Digits),_slippage,NormalizeDouble(_stoploss,Digits),NormalizeDouble(_takeprofit,Digits),_comment,_magic,_expiration,_arrow_color);

if(ticket<=0) {

Write("Error Occured : "+ErrorDescription(GetLastError()));

Write(Symbol()+" Buy Limit @ "+_priceop+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

tries++;

} else {

tries = NumberOfTries;

Write("Order opened : "+Symbol()+" Buy Limit @ "+_priceop+" SL @ "+_stoploss+" TP @"+_takeprofit+" ticket ="+ticket);

}

Sleep(RetryTime*1000);

}

err=ticket;

break;

 

pending orders

 2014.09.16 12:31:37.841        '324558': order buy stop 0.01 EURUSD opening at 1.29560 sl: 1.29527 tp: 1.29627 failed [Invalid S/L or T/P]

2014.09.16 12:31:37.666 '324558': pending order buy stop 0.01 EURUSD at 1.29560 sl: 1.29527 tp: 1.29627

2014.09.16 12:31:37.461 '324558': order buy stop 0.01 EURUSD opening at 1.29560 sl: 1.29527 tp: 1.29627 failed [Invalid S/L or T/P]

2014.09.16 12:31:37.298 '324558': pending order buy stop 0.01 EURUSD at 1.29560 sl: 1.29527 tp: 1.29627


 2014.09.16 12:31:37.845        I_Will_Make_You_Rich-1.02 EURUSD,H1:  Time 2014.09.16 13:31:45: EURUSD Buy Stop @ 1.29557 SL @ 1.29527 TP @1.29627 ticket =-1

2014.09.16 12:31:37.843 I_Will_Make_You_Rich-1.02 EURUSD,H1:  Time 2014.09.16 13:31:45: Error Occured : invalid stops

2014.09.16 12:31:37.466 I_Will_Make_You_Rich-1.02 EURUSD,H1:  Time 2014.09.16 13:31:45: EURUSD Buy Stop @ 1.29557 SL @ 1.29527 TP @1.29627 ticket =-1

2014.09.16 12:31:37.464 I_Will_Make_You_Rich-1.02 EURUSD,H1:  Time 2014.09.16 13:31:45: Error Occured : invalid stops

 
Please edit and use SRC (besides the video icon). Can't see a thing here.
 
xan023:


I have a problem with the wrong sl and tp tester everything is working properly

What is your Stoplevel value ?

 

 Requirements and Limitations in Making Trades

 
2 to 3 pips  function MarketInfo(_symbol,MODE_STOPLEVEL)  returns a value of zero
 
int stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
 
deysmacro:
int stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);

 

 _symbol = Symbol();

thanks for the help I changed lines

int _stoplevel=MarketInfo(_symbol,MODE_STOPLEVEL);

 to 

 int _stoplevel=30*Point;

 everything works

Reason: