On an hedge account you need to set the ticket and use an opposite deal.
it doesn't work either if i use the ticket
What does that means ?
On an hedge account you need to set the ticket and use an opposite deal.
What does that means ?
I have 2 results:
With one account without hedge i got this and it works perfectly. I opened one operation with 2 lots and i sold one with the first profit and the second with the second profit.
With one account with hedge i got this, it doesn't work. I opened one operation with 2 lots and it opened another with 2 lots independent of the first.
I used this code for both:
if(IsNewBar) { if(!compra) { trade.Buy(Lot); //ticket1=PositionGetTicket(0); compra=true; }else{ ulong ticket1=PositionGetTicket(0); if(PositionSelectByTicket(ticket1)) { Print("TICKET COMPRA: ", ticket1); if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) { double pr=(SymbolInfoDouble(_Symbol,SYMBOL_BID)-PositionGetDouble(POSITION_PRICE_OPEN))/_Point; if(pr>=Profit1 && partido==false) { MqlTradeRequest request={0}; MqlTradeResult result={0}; request.type=ORDER_TYPE_SELL; request.price=SymbolInfoDouble(_Symbol,SYMBOL_BID); request.action=TRADE_ACTION_DEAL; request.symbol=_Symbol; request.volume=PositionGetDouble(POSITION_VOLUME)/2; request.sl=0.0; request.tp=0.0; request.deviation=0; request.type_filling=ORDER_FILLING_FOK; if(!OrderSend(request,result)) { Print("Ha fallado la operación"); Print(result.retcode); return; } Print("CIERRA LA COMPRA 1: HA LLEGADO AL PROFIT"); ulong ticket2=PositionGetTicket(1); Print("TICKET VENTA: ", ticket2); partido=true; return; } if(pr>=Profit2) { trade.PositionClose(_Symbol); compra=false; partido=false; return; } /*if(pr<=-Stop) { trade.PositionClose(_Symbol); compra=false; return; }*/ } } } }
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.
What does that means ?
request.position = ticket;
- 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 wanna open an operation with 2 lots and i wanna sell one lot When the profit is got and after When the second profit is got, i close the position.
This code works good with an account without hedge but with hedge i can't close with the opposite action. What do i need?
it doesn't work either if i use the ticket
NOTE: i know than if i work with more of one open positions i need a loop with PositionsTotal but here its one to one
I have this code:
Thank you.