sell order and POSITION_TYPE_BUY

 

I just sell GBPUSD, try test the code for modify stoploss,

bool Robot::ModifyPosition()
  {

  
   bool res=false;

   if(m_position.Select(Symbol()))
        {
         if(m_position.Type()==POSITION_TYPE_BUY)
           {
             //the robot run this code for a sell order

 what is the wrong? is m_position error?

 
codeidea:

I just sell GBPUSD, try test the code for modify stoploss,

 what is the wrong? is m_position error?

if have fix it,

if(m_position.Type()==POSITION_TYPE_BUY) 

change to:

if(m_position.PositionType()==POSITION_TYPE_BUY)  

 

There are more code use Type() , it is for the class type, oh,wish this can help you 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5