I have an OCO EA where it doesn't take the trade because it seems that price containg to many digits.
Error in the 'Journal' tab: 'invalid price 1.59805567 for order send function' (i'm using 5 digit broker)
Here is the code that should send the trade order and below that is a function called 'OpenPendingOrder' that is used by the first section of the code.
How can I solve the problem with order price is not correct?I wasn't allowed to send the function code so here it is.
int OpenPendingOrder(int pType=OP_BUYLIMIT,double pLots=1,double pLevel=5,int sp=0, double sl=0,double tp=0,string pComment="",int pMagic=123,datetime pExpiration=0,color pColor=Yellow) { switch (pType) { case OP_BUYLIMIT: Alert("BUYLIMIT - Ask:",Ask," Bid:",Bid," Open price:",Ask-(pLevel*Point)," StopLoss:",(Ask-pLevel*Point)-sl*Point); return(OrderSend(Symbol(),OP_BUYLIMIT,pLots,Ask-(pLevel*Point),sp,(Ask-pLevel*Point)-sl*Point,(Ask-pLevel*Point)+tp*Point,pComment,pMagic,pExpiration,pColor)); break; case OP_BUYSTOP: Alert("BUYSTOP - Ask:",Ask," Bid:",Bid," Open price:",Ask+(pLevel*Point)," StopLoss:",(Ask+pLevel*Point)-sl*Point); return(OrderSend(Symbol(),OP_BUYSTOP,pLots,Ask+(pLevel*Point),sp,(Ask+pLevel*Point)-sl*Point,(Ask+pLevel*Point)+tp*Point,pComment,pMagic,pExpiration,pColor)); break; case OP_SELLLIMIT: Alert("SELLLIMIT - Ask:",Ask," Bid:",Bid," Open price:",Bid+(pLevel*Point)," StopLoss:",(Bid+pLevel*Point)+sl*Point); return(OrderSend(Symbol(),OP_SELLLIMIT,pLots,Bid+(pLevel*Point),sp,(Bid+pLevel*Point)+sl*Point,(Bid+pLevel*Point)-tp*Point,pComment,pMagic,pExpiration,pColor)); break; case OP_SELLSTOP: Alert("SELLSTOP - Ask:",Ask," Bid:",Bid," Open price:",Bid-(pLevel*Point)," StopLoss:",(Bid-pLevel*Point)+sl*Point); return(OrderSend(Symbol(),OP_SELLSTOP,pLots,Bid-(pLevel*Point),sp,(Bid-pLevel*Point)+sl*Point,(Bid-pLevel*Point)-tp*Point,pComment,pMagic,pExpiration,pColor)); break; } }
NormalizeDouble(xDistance,Digits); // Did you check StopLevel currency
Thanks deVries,
Here is what i did, but it didn't seems to work. Same error.
double yDistance = NormalizeDouble(xDistance,Digits); total = OrdersTotal(); if(total < 1 || isNewSymbol(Symbol())) //&& Hour()==TimeOutHour && Minute()==TimeOutMinute)
short_ticket=OpenPendingOrder(OP_SELLSTOP,lots,yDistance,slippage,xStoploss,xTakeProfit,MagicNumber,0); long_ticket=OpenPendingOrder(OP_BUYSTOP,lots,yDistance,slippage,xStoploss,xTakeProfit,MagicNumber,0);
Isn't that the way to do it?
On ECN brokers you must open first and THEN set stops. on 5 digit brokers you must adjust pip vs points https://www.mql5.com/en/forum/141509
On pairs where ticksize is NOT equal to point, the open price must be adjusted. https://www.mql5.com/en/forum/137301
On ECN brokers you must open first and THEN set stops. on 5 digit brokers you must adjust pip vs points https://www.mql5.com/en/forum/141509
On pairs where ticksize is NOT equal to point, the open price must be adjusted. https://www.mql5.com/en/forum/137301
Thank you WHRoeder!
I will take a look at these two links.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have an OCO EA where it doesn't take the trade because it seems that price containg to many digits.
Error in the 'Journal' tab: 'invalid price 1.59805567 for order send function' (i'm using 5 digit broker)
Here is the code that should send the trade order and below that is a function called 'OpenPendingOrder' that is used by the first section of the code.
How can I solve the problem with order price is not correct?