close a position in hedged account - page 2

 
//+------------------------------------------------------------------+
//|                                                 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);
   my_trade.PrintResult();
  }
//+------------------------------------------------------------------+
 
Karputov Vladimir:

i checked  it.

not any information in journal.

do i reinstall meta trader5?

 

 
mohsen bahrami:

i checked  it.

not any information in journal.


 

Can not be. The information is printed in the journal tab.
 

And if so:

void OnStart()
  {
   my_trade.PositionClose(find_ticket);
   Print(my_trade.RequestActionDescription());
   my_trade.PrintResult();
  }
 
Karputov Vladimir:

thank you so much.

i reinstalled the metatrader and it worked correctly.

i appreciate you for you kindness

Best regerds 

 

And this code will display an error:

//+------------------------------------------------------------------+
//|                                                 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()
  {
   ResetLastError();
   if(!my_trade.PositionClose(find_ticket,100))
     {
      Print("Trade request failed. Error = ",GetLastError(),", retcode ",my_trade.ResultRetcode());
     }
   else
     {
      Print("ActionDescription: ",my_trade.RequestActionDescription());
      my_trade.PrintResult();
     }
  }
 
Karputov Vladimir:

And this code will display an error:

thank you
Reason: