A MACD(12, 26, 9) crossover opens the trade, but only when price is on the matching side of SuperTrend(3, 10) and RSI(14) is not stretched. Every trade uses a fixed 12 point stop and 18 point target. The strategy has not been backtested on this site yet.
| positionSize Contracts per trade | 1 |
| macdFast MACD fast length | 12 |
| macdSlow MACD slow length | 26 |
| macdSignalPeriod MACD signal length | 9 |
| rsiPeriod RSI length | 14 |
| longRsiMax No longs when RSI is at or above this | 65 |
| shortRsiMin No shorts when RSI is at or below this | 35 |
| stMultiplier SuperTrend ATR multiplier | 3 |
| stPeriod SuperTrend ATR length | 10 |
| stopLossPoints Protective stop (points) | 12 |
| takeProfitPoints Profit target (points) | 18 |
The code
Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.
// ============================================================ // MACD SuperTrend Scalper // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- positionSize = 1 // contracts per trade macdFast = 12 // MACD fast length macdSlow = 26 // MACD slow length macdSignalPeriod = 9 // MACD signal length rsiPeriod = 14 // RSI length longRsiMax = 65 // no longs when RSI is at or above this shortRsiMin = 35 // no shorts when RSI is at or below this stMultiplier = 3 // SuperTrend ATR multiplier stPeriod = 10 // SuperTrend ATR length stopLossPoints = 12 // protective stop (points) takeProfitPoints = 18 // profit target (points) // --- Indicators --- macdMain = MACDline[macdFast, macdSlow, macdSignalPeriod](close) macdTrigger = ExponentialAverage[macdSignalPeriod](MACDline[macdFast, macdSlow, macdSignalPeriod](close)) rsiValue = RSI[rsiPeriod](close) stValue = SuperTrend[stMultiplier, stPeriod]
16 more lines: the entry and exit rules.
Read this first
Questions
The code is a standard ProOrder system, but it has not been compile checked or backtested. Test it in ProBacktest first.
None yet. Point based stop and target values mean you should check they suit the instrument you pick.
At the default of 1 contract the stop is 12 points plus spread. No drawdown figure exists yet because there is no backtest.
RSI(14) must be below 65 for longs and above 35 for shorts, which skips crossovers that happen after price has already run far.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.