거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
12575
평가:
(30)
게시됨:
2017.11.03 11:43
업데이트됨:
2018.02.28 10:46
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

If a trade is closed by Stop loss, the volume is doubled; if it's closed by Take profit the minimum volume is used. OnTradeTransaction is used to determine whether a trade was performed after the activation of Stop loss or Take profit.

The excellent enumeration ENUM_DEAL_REASON was added in build 1625:

ENUM_DEAL_REASON Reason description
... ...
DEAL_REASON_SL The operation was executed as a result of Stop Loss activation
DEAL_REASON_TP The operation was executed as a result of Take Profit activation
... ...

It can be checked in OnTradeTransaction.

In other words, it is a very simple and reliable way to determine that a trade resulted from Take Profit or Stop Loss.

At the moment (build 1626), this Expert Advisor can only be checked in a live test - by launching it on a chart or in a debug mode on real data (F5 in the MetaEditor editor). I used the following bypass maneuver:

In OnTradeTransaction, we determined whether Take Profit or Stop Loss triggered:

      if(deal_symbol==m_symbol.Name() && deal_magic==m_magic)
         if(deal_entry==DEAL_ENTRY_OUT)
           {
            if(deal_reason==DEAL_REASON_SL)
               ExtLot*=2.0;
            else if(deal_reason==DEAL_REASON_TP)
               ExtLot=m_symbol.LotsMin();
           }

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/18755

AFStar AFStar

A semaphore signal indicator.

ZigZagOnParabolic_channel ZigZagOnParabolic_channel

A channel based on peaks and troughs of ZigZagOnParabolic.

ColorFisher_m11 ColorFisher_m11

Oscillator using inverse Fisher Transform.

iCCI iMA iCCI iMA

The iMA (Moving Average) indicator based on iCCI (Commodity Channel Index). It is an analogue of Previous Indicator's Data in the terminal.