Problems on Closing Trades
If you come from MT4, I suppose you are using an hedging account (please check as it could also be a netting account which is working differently).
With an hedging account, you have to specify the position ticket to close a given position, also you have to specify an opposite deal.
Forum on trading, automated trading systems and testing trading strategies
Alain Verleyen, 2016.04.15 08:07
- 2016.03.21
- MetaQuotes Software Corp.
- www.mql5.com
Thanks Alain,
i have an heding account, but what is wrong on my code?
accorrding the MQL documentation it should work, but it doesnt
Amando
Thanks Alain,
i have an heding account, but what is wrong on my code?
accorrding the MQL documentation it should work, but it doesnt
Amando
Hello,
i try to convert my EA from MT4 to MT5 and now i have the problem to close all position, in MT4 it was easy to say at a spezific time to close everything.
now on mt5 i use following code
{
if(PositionSelect(_Symbol)==true)
{
for(k=0;k<=PositionsTotal();k--)
{
ClosePosition();
}
}
}
in this case i use for the time
{
MqlDateTime tm;
TimeCurrent(tm);
return(tm.min);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int Sekunde()
{
MqlDateTime tm;
TimeCurrent(tm);
return(tm.sec);
}
and for Position Close
{
MqlTradeRequest CloseOrder={0};
MqlTradeResult result;
//--- setting request
CloseOrder.symbol = _Symbol;
CloseOrder.deviation = 300;
return(OrderSendAsync(CloseOrder,result));
}
does anyone have an idea why its not working?
amando