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.
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
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 :
- 2016.08.01
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use