Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input int InpFastEMA = 12;
- input int InpSlowEMA = 26;
- input int InpSignalSMA = 9;
- #include <indicator_template_setup.mqh>
- void start()
- {
- double lot = 0.1; // so 1 pip = 1 dollar
- if(Volume[0] != 1) return; // only trade on candle beginning
- pipValue = get_pip_value(); // get pip value
- //
- // PUT YOUR CODE BELOW HERE:
- //
- int signal = 0;
- double indic = get_MACD(0, 1, InpFastEMA, InpSlowEMA, InpSignalSMA);
- if(indic > 0) signal = +1;
- if(indic < 0) signal = -1;
- //
- // execute indicator signal
- if(signal == +1) // indicator returned BUY (+1)
- { // ... so ...
- close_orders(-1); // close all SELL (-1) orders
- if(open_trades() == 0) // and if there are no trades open
- trade (+1); // go LONG (+1)
- }
- if(signal == -1) // indicator returned SELL (-1)
- { // ... so ...
- close_orders(+1); // close all BUY (+1) orders
- if(open_trades() == 0) // and if there are no trades open
- trade (-1); // go SHORT (-1)
- }
- }
- /*
- Modes:
- 0 == ExtMacdBuffer named '"MACD"', of type DRAW_HISTOGRAM
- 1 == ExtSignalBuffer named '"Signal"', of type DRAW_LINE
- */
- double get_MACD (int which_mode, int which_bar = 1, int InpFastEMA = 12, int InpSlowEMA = 26, int InpSignalSMA = 9)
- {
- return iCustom(Symbol(), 0, "MACD", InpFastEMA, InpSlowEMA, InpSignalSMA, which_mode, which_bar);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement