ReverseShort

숏 포지션의 리버스 작업을 수행합니다.

virtual bool  ReverseShort(
   double    price,    // 가격
   double    sl,       // 스탑 로스
   double    tp        // 이익 실현
   )

Parameters

price

[in]  시장 진입가.

sl

[in] 스탑 로스 가격.

tp

[in] 이익 실현 가격.

반환 값

거래 작업이 수행되었으면 true, 그게 아니면 false.

참고

거래량이 0이 아닐 경우 포지션 리버스(LotReverse(...) 메서드)을 가져오고 숏 포지션 반전(거래 객체의 Buy() 메서드) 트레이딩 연산을 수행합니다.

포지션 계산의 "헤징" 모드에서 포지션 리버스는 기존 포지션을 클로즈하고 남은 볼륨으로 새로운 반전 포지션을 오픈할 때 수행됩니다.

Implementation

//+------------------------------------------------------------------+
//| 숏 포지션 리버스                                           |
//| INPUT:  price - 가격,                                           |
//|         sl    - 스탑 로스,                                       |
//|         tp    - 이익 실현.                                     |
//| OUTPUT: 거래 작업이 처리되면 true, 그렇지 않으면 false.      |
//| 비고: no.                                                      |
//+------------------------------------------------------------------+
bool CExpert::ReverseLong(double price,double sl,double tp)
  {
   if(price==EMPTY_VALUE)
      return(false);
//--- 리버스용 로트 가져오기
   double lot=LotReverse(sl);
//--- 로트 확인하기
   if(lot==0.0)
      return(false);
//---
   bool result=true;
   if(m_margin_mode==ACCOUNT_MARGIN_MODE_RETAIL_HEDGING)
     {
      //--- first close existing position
      lot-=m_position.Volume();
      result=m_trade.PositionCloseByTicket(m_position.Identifier());
     }
   if(result)
      result=m_trade.Sell(lot,price,sl,tp);
//---
   return(result);
  }