거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
Experts

MACD and SAR - MetaTrader 5용 expert

게시자:
Vladimir Karputov
조회수:
4382
평가:
(8)
게시됨:
2018.06.18 10:52
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Idea by: Gatis.

MQL5 code by: Vladimir Karputov.

The EA analyzes four parameters:

  1. Value of the main line of MACD on bar #1 (macd_main_1)
  2. Value of the signal line of MACD on bar #1 (macd_signal_1)
  3. Value of indicator SAR on bar #1 (sar_1) relative to price Bid (m_symbol.Bid())

These parameters are combined in the basic formula of signals for Buy and Sell:

bool open_buy        = (macd_main_1>macd_signal_1 && macd_signal_1<0 && sar_1<m_symbol.Bid());
   bool open_sell       = (macd_main_1<macd_signal_1 && macd_signal_1>0 && sar_1>m_symbol.Bid());

However, you can optimize the values of signs < and > in any part of the formula. To do so, for each of signs < and >, their own variables (InpMoreLessBuy_1, InpMoreLessBuy_2, InpMoreLessBuy_3, InpMoreLessSell_1, InpMoreLessSell_2, and InpMoreLessSell_3) are introduced. With these variables, the basic formula is modified as follows:

bool open_buy=    (InpMoreLessBuy_1   ? macd_main_1>macd_signal_1      : macd_main_1<macd_signal_1) && 
                  (!InpMoreLessBuy_2  ? macd_signal_1 < 0              : macd_signal_1 > 0 ) &&
                  (!InpMoreLessBuy_3  ? sar_1         < m_symbol.Bid() : sar_1         > m_symbol.Bid() );
   bool open_sell=(!InpMoreLessSell_1 ? macd_main_1<macd_signal_1      : macd_main_1>macd_signal_1) && 
                  (InpMoreLessSell_2  ? macd_signal_1 > 0              : macd_signal_1 < 0 ) &&
                  (InpMoreLessSell_3  ? sar_1         > m_symbol.Bid() : sar_1         < m_symbol.Bid() );

The EA itself only operates when a new bar appears. When a signal is received, positions opposite to the signal received will be closed.

When optimizing the formula, it would also be reasonable to optimize the number of positions:

MACD and SAR optimization

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

Executor Candles Executor Candles

Trading on several candlestick patterns. The levels of Take Profit, Stop Loss, and Trailing are separate for BUY and SELL.

Night Flat Trade Night Flat Trade

The EA works in the quietest hours (upon closing the American session and before opening the Asian session).

ATR_Normalize_Histogram ATR_Normalize_Histogram

A typical oscillator using Average True Range in form of a multicolor histogram.

ATR_Normalize_Histogram_HTF ATR_Normalize_Histogram_HTF

Indicator ATR_Normalize_Histogram with the timeframe selection option available in input parameters, alerting when the overbought/oversold zones are broken through.