• Get access

Close partial o.k. but how open (reopen the same position)

To add comments, please log in or register
hlucas
10
hlucas  

Hi,

I can't solve the problem.

The code snippet works to close partial positions with the same ticket, but how can I increase the position ???

I looked everywhere, I tray with the negative - but it doesn't work.

Anyone got any idea? Or it's impossible in mql5?


   if(account.Profit() > 600 /*&& positionvolumen==0.6*/)
     {
      trade.PositionClosePartial(positionticket,0.2,-1);
     }


I know I can open a position with a new ticket, but this requires more management. 

Thansk for help **#

Vladimir Karputov
Moderator
173607
Vladimir Karputov  

To insert the code, please use the button Code.


If you are not working on a hedge account, then you cannot increase the position size, you can only open a new position. If you work on a netting account, then increasing the position size is very easy: you need to send a new trading order.

hlucas
10
hlucas  
Vladimir Karputov:

To insert the code, please use the button .


If you are not working on a hedge account, then you cannot increase the position size, you can only open a new position. If you work on a netting account, then increasing the position size is very easy: you need to send a new trading order.

Thanks, I use it.

 /*---------------------------OTWIERANIE I ZAMYKANIE POZYCJI--------------------------*/
//sprawdzanie jaka wartość została przypisana do zmiennej signal i ZAWARCIE TRANSAKCJI
   if(dif_TA=="TA---buy" && position=="sell-in" && PositionsTotal()>0)
     {
      trade.PositionClose(positionticket);
     }
   if(dif_TA=="TA---buy" && PositionsTotal()==0)
     {
      trade.Buy(0.60, NULL, Ask, NULL /*(Ask -200 * _Point)*/, NULL, "eu20m-v.101.x005");
     }
   if(dif_TA=="TA---sell" && position=="buy-in" && PositionsTotal()>0)
     {
      trade.PositionClose(positionticket);
     }
   if(dif_TA=="TA---sell" && PositionsTotal()==0)
     {
      trade.Sell(0.60, NULL, Bid, NULL /*(Bid +200 * _Point)*/, NULL, "eu20m-v.101.x005");
     }
   /*-------------------------------------------------x001----------------------------------------------------------------------*/


   /*---------------------WARUNKI MODYFIKACJI POZYCJI--------------------*/

   if(account.Profit() > 100 /*&& positionvolumen==0.6*/)
     {
      trade.PositionClosePartial(positionticket,0.2,-1);
     }
   
   
   if(difprice_AMA < 100 && position=="sell-in" && positionvolumen == 0.4)
     {
      trade.Buy(0.20, NULL, Ask, NULL /*(Ask -200 * _Point)*/, NULL, "eu20m-v.101.x005");
     }
   if(difprice_AMA < 100 && position=="buy-in" && positionvolumen == 0.4)
     {
      trade.Sell(0.20, NULL, Bid, NULL /*(Bid +200 * _Point)*/, NULL, "eu20m-v.101.x005");
     }    


Look at the situation on the screen. You think it's the account's fault? I have a demo account - hedge. 

I did not find the reverse PositionClosePartial command and as I wrote the minus parameter does not work :) but I also had to check.

Vladimir Karputov
Moderator
173607
Vladimir Karputov  

Please run this code.

I have this result: there is a position SELL. After PositionClosePartial, the SELL position remains, only with a smaller volume.


To add comments, please log in or register