Error 130 & 129

 
Hello everyone, How can i solve the problem of error 130 & 129 here:
ticket=OrderSend("NZDCHF",OP_BUY,1.0,Open[0],0,Low[0]-200*Point,High[0]+200*Point,NULL,0,0,Green);
 
dominiK990628:
Hello everyone, How can i solve the problem of error 130 & 129 here:

Does your EA call OrderSend() at the start of a candle, or at any tick?

Anyway, you can test using Ask instead of Open[0].

And instead of 200, use 500 - see if that removes all the errors... if so, that means you just need a value larger than 20 pips.

 
dominiK990628:
Hello everyone, How can i solve the problem of error 130 & 129 here:

Please don't just post the error code, post what the error is. eg. "Invalid Stops".

This will mean that people don't have to look up what the code means. Some people will not do that and so will not help you.

Why are you using Open[0] as the order open price? Price could have moved from the bar open price. Also it will be a Bid price and you are opening a Buy order that requires an Ask price.

 
ticket=OrderSend("NZDCHF",OP_BUY,1.0,Open[0],0,NormalizeDouble(Low[0]-200*Point,Digits),NormalizeDouble(High[0]+200*Point,Digits),NULL,0,0,Green);

try this

 
You buy at the Ask and sell at the Bid. You can't make a buy market order at Open[0] (a Bid price.)
 
int orderType=OP_BUY;
if(orderType<=OP_SELL){
double SL=orderType==OP_BUY?NormalizeDouble(iLow("NZDCHF",0,0)-200*MarketInfo("NZDCHF",MODE_POINT),MarketInfo("NZDCHF",MODE_DIGITS)):NormalizeDouble(iHigh("NZDCHF",0,0)+200*MarketInfo("NZDCHF",MODE_POINT),MarketInfo("NZDCHF",MODE_DIGITS));
double TP=orderType==OP_BUY?NormalizeDouble(iHigh("NZDCHF",0,0)+200*MarketInfo("NZDCHF",MODE_POINT),MarketInfo("NZDCHF",MODE_DIGITS)):NormalizeDouble(iLow("NZDCHF",0,0)-200*MarketInfo("NZDCHF",MODE_POINT),MarketInfo("NZDCHF",MODE_DIGITS));
int ticket=OrderSend("NZDCHF",orderType,1.0,orderType==OP_BUY?MarketInfo("NZDCHF",MODE_ASK):MarketInfo("NZDCHF",MODE_BID),4,SL,TP,NULL,0,0,orderType==OP_BUY?clrGreen:clrRed);
}

The SL-TP should be checked by MarketInfo(_Symbol,MODE_STOPLEVEL),it can be very tight values,

And others like lot size should be checked too.

For more info :

https://www.mql5.com/en/articles/2555

https://www.mql5.com/en/forum/92921

Discussion of article "The checks a trading robot must pass before publication in the Market"
Discussion of article "The checks a trading robot must pass before publication in the Market"
  • 2016.08.01
  • www.mql5.com
New article The checks a trading robot must pass before publication in the Market has been published: Author: MetaQuotes Software Corp...
Reason: