A trade needs SuperTrend(3, 5) to turn after a limited run, Parabolic SAR on the right side of price, and a MACD histogram move above a set size. A smoothed buy and sell pressure reading must agree. This strategy has not been backtested yet.
| positionSize Size per point | 1 |
| stMultiplier SuperTrend ATR multiplier | 3 |
| stPeriod SuperTrend ATR length | 5 |
| sarStart Parabolic SAR start factor | 0.02 |
| sarStep Parabolic SAR step | 0.02 |
| sarMax Parabolic SAR maximum factor | 0.03 |
| macdFast MACD fast length | 12 |
| macdSlow MACD slow length | 26 |
| macdLineArg Third MACDline argument, as published | 150 |
| macdSignalPeriod EMA of the MACD line used as signal | 9 |
| lookbackPeriod Window for the pressure calculation | 100 |
| pressurePeriod EMA length that smooths buy and sell pressure | 500 |
| minTrendBars SuperTrend must have held its side longer than this | 15 |
| longMacdSlope Minimum rise of the MACD histogram for longs (points) | 0.045 |
| shortMacdSlope Minimum fall of the MACD histogram for shorts (points) | 0.186 |
| minRangePips Previous bar range must exceed this (pips) | 2 |
| takeProfitPoints Profit target (points) | 10 |
| stopLossPoints Protective stop (points) | 10 |
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.
// ============================================================ // SuperTrend SAR MACD // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- positionSize = 1 // size per point stMultiplier = 3 // SuperTrend ATR multiplier stPeriod = 5 // SuperTrend ATR length sarStart = 0.02 // Parabolic SAR start factor sarStep = 0.02 // Parabolic SAR step sarMax = 0.03 // Parabolic SAR maximum factor macdFast = 12 // MACD fast length macdSlow = 26 // MACD slow length macdLineArg = 150 // third MACDline argument, as published macdSignalPeriod = 9 // EMA of the MACD line used as signal lookbackPeriod = 100 // window for the pressure calculation pressurePeriod = 500 // EMA length that smooths buy and sell pressure minTrendBars = 15 // SuperTrend must have held its side longer than this longMacdSlope = 0.045 // minimum rise of the MACD histogram for longs (points) shortMacdSlope = 0.186 // minimum fall of the MACD histogram for shorts (points) minRangePips = 2 // previous bar range must exceed this (pips) takeProfitPoints = 10 // profit target (points) stopLossPoints = 10 // protective stop (points) ONCE stNotRisingBars = 0 // bars in a row the SuperTrend has not risen ONCE stNotFallingBars = 0 // bars in a row the SuperTrend has not fallen // --- Indicators --- stValue = SuperTrend[stMultiplier, stPeriod] sarValue = SAR[sarStart, sarStep, sarMax] macdMain = MACDline[macdFast, macdSlow, macdLineArg](close) macdTrigger = ExponentialAverage[macdSignalPeriod](MACDline[macdFast, macdSlow, macdLineArg](close)) macdHistogram = macdMain - macdTrigger barRange = Range // Buying versus selling pressure over the lookback window, smoothed. channelLow = Lowest[lookbackPeriod](low) channelHigh = Highest[lookbackPeriod](high) buyPressure = 100 * (3 * close - 2 * channelLow - open[lookbackPeriod - 1]) / CustomClose sellPressure = 100 * (open[lookbackPeriod - 1] + 2 * channelHigh - 3 * close) / CustomClose pressureSpread = ExponentialAverage[pressurePeriod](buyPressure) - ExponentialAverage[pressurePeriod](sellPressure) IF stValue[2] >= stValue[1] THEN stNotRisingBars = stNotRisingBars + 1 ELSE stNotRisingBars = 0 ENDIF IF stValue[1] >= stValue[2] THEN stNotFallingBars = stNotFallingBars + 1 ELSE stNotFallingBars = 0 ENDIF
17 more lines: the entry and exit rules.
Read this first
Questions
The code is written for ProOrder, but it has not been compile-checked or backtested yet. Treat it as a starting point for your own tests.
None yet. Results will be added once it has been through the test battery.
It trades a size of 1 per point. With no backtest there is no drawdown figure yet, so start small in demo.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.