close a position in hedged account

 

hi.

i want to close an specific  position in hedged account without opening another opposite position. who can i do it?

thanks.

 
mohsen bahrami:

hi.

i want to close an specific  position in hedged account without opening another opposite position. who can i do it?

thanks.

On the hedge account it becomes so:

//+------------------------------------------------------------------+
//|                                                 Test_script.mql5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property script_show_inputs
#include <Trade\Trade.mqh>
//--- input
input ulong find_ticket=0; // ticket of position
//--- variable
CTrade my_trade;
//+------------------------------------------------------------------+
//| OnStart                                                          |
//+------------------------------------------------------------------+
void OnStart()
  {
   my_trade.PositionClose(find_ticket);
  }
//+------------------------------------------------------------------+

Was:

Was

Became:

Became 

Files:
 
Karputov Vladimir:

On the hedge account it becomes so:

Was:


Became:

 

thanks. but in mql5, PositionClose in "hedged account" does'nt work.

Files:
mm.png  45 kb
 
mohsen bahrami:

thanks. but in mql5, PositionClose in "hedged account" does'nt work.

I have given an example for the hedge account: attentively look at the first pictures, above, at the left - "Hedge":

hedge

 
Everything works fine. And netting accounts and hedge accounts.
 
Karputov Vladimir:
Everything works fine. And netting accounts and hedge accounts.

you are right.

thanks alot 

 
Karputov Vladimir:
Everything works fine. And netting accounts and hedge accounts.

I checked it again as attached pics. after running the script. not happening.

//+------------------------------------------------------------------+
//|                                                 Test_script.mql5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property script_show_inputs
#include <Trade\Trade.mqh>
//--- input
input ulong find_ticket=0; // ticket of position
//--- variable
CTrade my_trade;
//+------------------------------------------------------------------+
//| OnStart                                                          |
//+------------------------------------------------------------------+
void OnStart()
  {
   Print("------------");
   if(my_trade.PositionClose(find_ticket))
      Print("closed");
   else Print("not closed");
  }
//+------------------------------------------------------------------+
 
mohsen bahrami:

I checked it again as attached pics. after running the script. not happening.

  1. Before running the script: Show screenshot window "Trade" and window "History".
  2. Then show that you have entered in the input parameter of the script.
  3. Show terminal screenshot - I want to see the type of your account (hedge or netting).
  4. Turn on the terminal "Automated Trading" button.
 
Karputov Vladimir:

  1. Before running the script: Show screenshot window "Trade" and window "History".
  2. Then show that you have entered in the input parameter of the script.

 

 

 

 

 

 

 

Button "AutoTraiding"!

 AutoTraiding

 
Karputov Vladimir:

Button "AutoTraiding"!

 

 

 

 

 

 

Reason: