emmett_brown:
Is it a Buy or a Sell ? You close a Buy at Bid and a Sell at Ask . . . or just use OrderClosePrice()
Hello, I have a problem when I must close an order, it does not work; there is an "invalid price" error (129) althought the programm seems good
emmett_brown:
wrong, use double bid, or instead to make a mess always use OrderClosePrice() as raptor said
In this example, it is a buy order at Ask and I have to close it at Bid but I have seen the error wich was as BIG as the german chancellor bottom!
==>
I use int prix = Bid instead of double prix = Bid ;)
Thanks
Correct I would say "I used ...", not "I use"
But OrderClosePrice is for knowing the Close price of a closed order, isn't it?
Or for the price you can close it?
Here the order is not closed yet, am I wrong?
c 4 yourself
Returns close price for the currently selected order.
double OrderClosePrice( | ) |
Note: The order must be previously selected by the OrderSelect() function.
Ok, closed or not;
closed !!!
Use OrderClosePrice() . . it works, try it for yourself if you do not want to believe us . .
retour = OrderClose (ticket, lot, prix, 3, Orange); if (retour < 1) {
OrderClose returns a bool not a int so retour < 1 makes no sense.if (!OrderClose (OrderTicket(), OrderLots(), OrderClosePrice(), 3, Orange) Alert("OrderClose failed: ", GetLastError());
int ticket = OrderTicket (); if (ordre == 1) { // si ordre d'achat
What is ordre and what does 1 mean. It's not the order type since the variable isn't ever set in the posted code.prix, 3, Orange
Code fails on a 5 digit broker. EA's must adjust TP, SL, and SLIPPAGE for 4 vs 5 digit brokers.//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I have a problem when I must close an order, it does not work; there is an "invalid price" error (129) althought the programm seems good