OrderClose(OrderTicket(),OrderLots(),OrderOpenPrice(),MaxSlippage,clrNONE)
OrderClose(OrderTicket(),OrderLots(),Ask,MaxSlippage,clrNONE)
if(OrderType()==OP_SELL) if(!OrderClose(OrderTicket(),OrderLots(),OrderOpenPrice(),MaxSlippage,clrNONE))
- You can't close at the open price, only the current market price.
- For a sell that is the Ask. You can also use OrderClosePrice and be direction independent.
- Is MaxSlippage in points? Or have you adjusted for 4/5 digit brokers?
And
- You can't close at the open price, only the current market price.
- For a sell that is the Ask. You can also use OrderClosePrice and be direction independent.
- Is MaxSlippage in points? Or have you adjusted for 4/5 digit brokers?
Thnak you, the problem was i didn't use ask/bid for closing price, such stupid.
Max Slippage is in point.
I have this for pisps in the initialization function.
Pips=Point;// 0.0001 and 0.01 on old broker or .00001 and .001 on new broker if(Digits==5 || Digits==3)Pips*=10;//0.00001 becomes 0.0001 and 0.001 becomes 0.01
but when i try to multiply Maxslippage*Pips i get "Possible loss of data due to type conversion" i can't get rid of it!
Do a type-cast like
(double)Maxslippage*Pips; // my crystal ball advised me that Maxslippage might have defined as int
Do a type-cast like
(double)Maxslippage*Pips; // my crystal ball advised me that Maxslippage might have defined as int
MaxSlippage is int Type even if i TypeCasto to double as you said i get the same error, that's why i can't get rid of it, i already tried that.
OrderClose(OrderTicket(),OrderLots(),Bid,(double)MaxSlippage*Pips,clrNONE)
input int Slippage=5; int Maxslippage;
MaxSlippage=Slippage; Pips=Point;// 0.0001 and 0.01 on old broker or .00001 and .001 on new broker if(Digits==5 || Digits==3) //0.00001 becomes 0.0001 and 0.001 becomes 0.01 { Pips*=10; MaxSlippage*=10; }
.
.
In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading) you must count down when closing/deleting/modifying in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
Ok, i'll modify and post everything, but know i'm using a for loop from 0 to OrdersTotal(), incrementing everytime, and at the end i--, isn't the same thing?
anyway, something like that?
for(int i=OrdersTotal()-1; i>=0; i --)//Count down, from orders Total to 0 { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==_Symbol) if(OrderMagicNumber()==MagicNumber) if(OrderType()==OP_BUY) if(!OrderClose(OrderTicket(),OrderLots(),NormalizePrice(Bid),MaxSlippage,clrNONE)) { int err=GetLastError(); MessageBox(Symbol()+", Could not close the order due to error "+(string)err+" "+ErrorDescription(err),"OrderSend Error",0x00000010); } }
d_bignotti: i'm using a for loop from 0 to OrdersTotal(), incrementing everytime, and at the end i--, isn't the same thing?
| You didn't understand Loops and Closing or Deleting Orders - MQL4 forum. It's also about what if another unrelated order gets closed. |
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
i'm getting this error only in BACKTESTING, here's a pic.
As you can see i'm trying to close a Basket when a when an opposite signal is generated.
Here's the OrderClose() code for Sell orders, the same for Buy orders
Also i paste the OrderSend maybe the problem is there
Anyone know where's the problem?