Forum on trading, automated trading systems and testing trading strategies
Divide Volume with Hedge account
Alain Verleyen, 2016.06.23 13:28
On an hedge account you need to set the ticket and use an opposite deal.
Alain Verleyen:
for(i=PositionsTotal()-1; i>=0; i--) { if(ForAllSymbol || PositionGetSymbol(i)==Symbol()) { if(PositionGetTicket(i)== OrderGetTicket(i)) <<--- i just added this, is it correct ?? if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) { string PoSymb=PositionGetSymbol(i); long PoType=PositionGetInteger(POSITION_TYPE); double PoVolume=PositionGetDouble(POSITION_VOLUME); MqlTradeRequest request={0}; MqlTradeResult result={0}; request.action=TRADE_ACTION_DEAL; request.symbol=PoSymb; request.volume=PoVolume; request.sl=0; request.tp=0; request.deviation=3; request.type=ORDER_TYPE_SELL; request.price=SymbolInfoDouble(PoSymb,SYMBOL_BID); bool CloseAllBuy=OrderSend(request,result); } } }
forextime8:
No it's not correct, read the topic I gave the link please.
Alain Verleyen:
No it's not correct, read the topic I gave the link please.
No it's not correct, read the topic I gave the link please.
for(i=PositionsTotal()-1; i>=0; i--) { if(ForAllSymbol || PositionGetSymbol(i)==Symbol()) { if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) { string PoSymb=PositionGetSymbol(i); long PoType=PositionGetInteger(POSITION_TYPE); double PoVolume=PositionGetDouble(POSITION_VOLUME); ulong PoTicket=PositionGetTicket(i); <<====== correct ? MqlTradeRequest request={0}; MqlTradeResult result={0}; request.action=TRADE_ACTION_DEAL; request.symbol=PoSymb; request.volume=PoVolume; request.sl=0; request.tp=0; request.deviation=3; request.type=ORDER_TYPE_SELL; request.price=SymbolInfoDouble(PoSymb,SYMBOL_BID); bool CloseAllBuy=OrderSend(request,result); } } }
for(i=PositionsTotal()-1; i>=0; i--) { if(ForAllSymbol || PositionGetSymbol(i)==Symbol()) { if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) { string PoSymb=PositionGetSymbol(i); long PoType=PositionGetInteger(POSITION_TYPE); double PoVolume=PositionGetDouble(POSITION_VOLUME); ulong PoTicket=PositionGetTicket(i); <<====== added this & MqlTradeRequest request={0}; MqlTradeResult result={0}; request.action=TRADE_ACTION_DEAL; request.symbol=PoSymb; request.volume=PoVolume; request.position=PoTicket; <<====== this request.sl=0; request.tp=0; request.deviation=3; request.type=ORDER_TYPE_SELL; request.price=SymbolInfoDouble(PoSymb,SYMBOL_BID); bool CloseAllBuy=OrderSend(request,result); } } }
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
as we knw for MT5,
close sell order is by open the new buy order,
and close buy order is by open the sell order.
but how's in hedging MT5 acc ?
yesterday before markets close,
for my oneclickpad expert MT5,
when i m trying to close the buy order, but it is executing the new sell order.