SHOW:
|
|
- or go back to the newest paste.
| 1 | input int InpFastEMA = 12; | |
| 2 | input int InpSlowEMA = 26; | |
| 3 | input int InpSignalSMA = 9; | |
| 4 | ||
| 5 | ||
| 6 | #include <indicator_template_setup.mqh> | |
| 7 | ||
| 8 | void start() | |
| 9 | {
| |
| 10 | double lot = 0.1; // so 1 pip = 1 dollar | |
| 11 | if(Volume[0] != 1) return; // only trade on candle beginning | |
| 12 | pipValue = get_pip_value(); // get pip value | |
| 13 | ||
| 14 | // | |
| 15 | // PUT YOUR CODE BELOW HERE: | |
| 16 | // | |
| 17 | int signal = 0; | |
| 18 | double indic = get_MACD(0, 1, InpFastEMA, InpSlowEMA, InpSignalSMA); | |
| 19 | ||
| 20 | if(indic > 0) signal = +1; | |
| 21 | if(indic < 0) signal = -1; | |
| 22 | ||
| 23 | - | // |
| 23 | + | // |
| 24 | - | // execute indicator signal |
| 24 | + | // execute indicator signal |
| 25 | if(signal == +1) // indicator returned BUY (+1) | |
| 26 | { // ... so ...
| |
| 27 | close_orders(-1); // close all SELL (-1) orders | |
| 28 | trade (+1); // and go LONG (+1) | |
| 29 | } | |
| 30 | if(signal == -1) // indicator returned SELL (-1) | |
| 31 | { // ... so ...
| |
| 32 | close_orders(+1); // close all BUY (+1) orders | |
| 33 | trade (-1); // and go SHORT (-1) | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | /* | |
| 38 | Modes: | |
| 39 | 0 == ExtMacdBuffer named '"MACD"', of type DRAW_HISTOGRAM | |
| 40 | 1 == ExtSignalBuffer named '"Signal"', of type DRAW_LINE | |
| 41 | */ | |
| 42 | double get_MACD (int which_mode, int which_bar = 1, int InpFastEMA = 12, int InpSlowEMA = 26, int InpSignalSMA = 9) | |
| 43 | {
| |
| 44 | return iCustom(Symbol(), 0, "MACD", , InpFastEMA, InpSlowEMA, InpSignalSMA, which_mode, which_bar); | |
| 45 | } |