ФОРТС Модификация стоп-лимит ордера

 

Добрый день!

Возможна ли модификация стоп-лимит ордера, выставленного

с TP и SL?

void CStopOrder::Place( const double price, const double sl_price, const double volume, const bool buy_sell )
{
  MqlTradeRequest request = {0};
  MqlTradeResult  result  = {0};
  ticket = 0;
     
//--- Fill structure
  request.action = TRADE_ACTION_PENDING;
  request.magic = magic;
  request.symbol = _Symbol;
  request.volume = volume;
  request.price = price;
  request.stoplimit = sl_price;
    
  if ( buy_sell )
  {
    request.type = ORDER_TYPE_BUY_STOP_LIMIT;
    request.tp = sl_price + PointsToPrice( TProfit );
    request.sl = sl_price - PointsToPrice( StLoss );
  }
  else
  {
    request.type = ORDER_TYPE_SELL_STOP_LIMIT;
    request.tp = sl_price - PointsToPrice( TProfit );
    request.sl = sl_price + PointsToPrice( StLoss );
  } 
  request.comment = "Стоп-лимит ордер...";      
  request.type_filling = ORDER_FILLING_IOC;
  request.type_time = ORDER_TIME_DAY;
  
//--- Send order
  if ( OrderSend( request, result ) )
  {
    if ( result.retcode == TRADE_RETCODE_PLACED ) 
    {
      ticket = result.order;
      
    }
  }
  else
  {
    CheckError( result.retcode, "Place: Ордер не установлен!", order_status );
  }
}
 
Михаил:

Добрый день!

Возможна ли модификация стоп-лимит ордера, выставленного

с TP и SL?

Получилось

2015.06.29 22:24:32.175 Trades 'ххххх': modify order #14737510 buy stop limit 1.00 VTBR-9.15 at 7889 (7789) sl: 7689 tp: 7909 -> 7989 (7809), sl: 7609 tp: 8049 done in 37 ms

2015.06.29 22:24:32.138 Trades 'ххххх': modify order #14737510 buy stop limit 1.00 VTBR-9.15 at 7889 (7789) sl: 7689 tp: 7909 -> 7989 (7809), sl: 7609 tp: 8049

2015.06.29 22:24:27.136 Trades 'ххххх': buy stop limit 1.00 VTBR-9.15 at 7889 (7789) sl: 7689 tp: 7909 placed for execution in 35 ms

2015.06.29 22:24:27.100 Trades 'ххххх': buy stop limit 1.00 VTBR-9.15 at 7889 (7789) sl: 7689 tp: 7909

 

void Modify(ulong mticket, const double price, const double sl_price, const bool buy_sell )
{
  MqlTradeRequest request = {0};
  MqlTradeResult  result  = {0};
     
//--- Fill structure
  request.action = TRADE_ACTION_MODIFY;
  request.symbol = _Symbol;
  request.order = mticket;
  request.price = price;
  request.stoplimit = sl_price;
    
  if ( buy_sell )
  {
    request.type = ORDER_TYPE_BUY_STOP_LIMIT;
    request.tp = sl_price + PointsToPrice( NewTP );
    request.sl = sl_price - PointsToPrice( NewSL );
  }
  else
  {
    request.type = ORDER_TYPE_SELL_STOP_LIMIT;
    request.tp = sl_price - PointsToPrice( NewTP );
    request.sl = sl_price + PointsToPrice( NewSL );
  } 
  
//--- Send order
  if ( OrderSend( request, result ) )
  {
    if ( result.retcode == TRADE_RETCODE_PLACED ) 
    {
      ticket = result.order;
    }
  }
  else
  {
    Print( result.retcode, "   Place: Ордер не установлен!" );
  }
}
 
Спасибо
 

Для лучшей читаемости кода можно использовать вместо

const bool buy_sell
вот это
ENUM_ORDER_TYPE buy_sell
и в коде функции изменить условие
if(buy_sell == ORDER_TYPE_BUY_LIMIT)
так код будет нагляднее
 
Konstantin Karpov:

Для лучшей читаемости кода можно использовать вместо

вот этои в коде функции изменить условие так код будет нагляднее
Спасибо, сенсей.