Un trade exige que le SuperTrend(3, 5) se retourne après un parcours limité, que le Parabolic SAR soit du bon côté du prix, et que l'histogramme MACD bouge au-delà d'une taille définie. Une lecture lissée de la pression acheteuse et vendeuse doit concorder. Cette stratégie n'a pas encore été backtestée.
| positionSize Taille par point | 1 |
| stMultiplier Multiplicateur d'ATR du SuperTrend | 3 |
| stPeriod Longueur de l'ATR du SuperTrend | 5 |
| sarStart Facteur de départ du Parabolic SAR | 0.02 |
| sarStep Pas du Parabolic SAR | 0.02 |
| sarMax Facteur maximum du Parabolic SAR | 0.03 |
| macdFast Longueur rapide du MACD | 12 |
| macdSlow Longueur lente du MACD | 26 |
| macdLineArg Troisième argument de MACDline, tel que publié | 150 |
| macdSignalPeriod EMA de la ligne MACD utilisée comme signal | 9 |
| lookbackPeriod Fenêtre pour le calcul de la pression | 100 |
| pressurePeriod Période de l'EMA qui lisse la pression acheteuse et vendeuse | 500 |
| minTrendBars Le SuperTrend doit avoir tenu son côté plus longtemps que cette valeur | 15 |
| longMacdSlope Hausse minimale de l'histogramme MACD pour les longs (points) | 0.045 |
| shortMacdSlope Baisse minimale de l'histogramme MACD pour les shorts (points) | 0.186 |
| minRangePips L'amplitude du bar précédent doit dépasser cette valeur (pips) | 2 |
| takeProfitPoints Objectif de gain (points) | 10 |
| stopLossPoints Stop de protection (points) | 10 |
Le code
// ============================================================ // 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 lignes de plus : les règles d'entrée et de sortie.
Configuration
Questions
Le code est écrit pour ProOrder, mais il n'a pas encore été vérifié à la compilation ni backtesté. Considérez-le comme un point de départ pour vos propres tests.
Aucun pour l'instant. Les résultats seront ajoutés dès qu'elle aura passé la batterie de tests.
Elle trade une taille de 1 par point. Sans backtest, il n'y a pas encore de chiffre de drawdown, commencez donc petit en démo.
Voir aussi
La communauté ProRealAlgos obtient les règles complètes, le code complet et le portefeuille automatisé.