Een trade vereist dat SuperTrend(3, 5) omslaat na een beperkte reeks, dat de Parabolic SAR aan de juiste kant van de prijs staat en dat het MACD-histogram meer beweegt dan een vastgestelde omvang. Een gesmoothe meting van de koop- en verkoopdruk moet daarmee overeenstemmen. Deze strategie is nog niet gebacktest.
| positionSize Grootte per punt | 1 |
| stMultiplier SuperTrend ATR-multiplier | 3 |
| stPeriod SuperTrend ATR-lengte | 5 |
| sarStart Parabolic SAR startfactor | 0.02 |
| sarStep Parabolic SAR stap | 0.02 |
| sarMax Parabolic SAR maximumfactor | 0.03 |
| macdFast MACD snelle lengte | 12 |
| macdSlow MACD langzame lengte | 26 |
| macdLineArg Derde MACDline-argument, zoals gepubliceerd | 150 |
| macdSignalPeriod EMA van de MACD-lijn die als signaal wordt gebruikt | 9 |
| lookbackPeriod Venster voor de drukberekening | 100 |
| pressurePeriod EMA-lengte die de koop- en verkoopdruk smootht | 500 |
| minTrendBars De SuperTrend moet zijn kant langer dan dit hebben vastgehouden | 15 |
| longMacdSlope Minimale stijging van het MACD-histogram voor longs (punten) | 0.045 |
| shortMacdSlope Minimale daling van het MACD-histogram voor shorts (punten) | 0.186 |
| minRangePips De range van de vorige bar moet hier bovenuit komen (pips) | 2 |
| takeProfitPoints Profit target (punten) | 10 |
| stopLossPoints Beschermende stop (punten) | 10 |
De 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
Nog 17 regels: de instap- en uitstapregels.
Opzet
Vragen
De code is geschreven voor ProOrder, maar is nog niet op compileerfouten gecontroleerd en nog niet gebacktest. Beschouw hem als een startpunt voor je eigen tests.
Nog geen. Resultaten worden toegevoegd zodra hij door de testbatterij is.
Hij trade een grootte van 1 per punt. Zonder backtest is er nog geen drawdowncijfer, dus begin klein in demo.
Gerelateerd
De ProRealAlgos community krijgt de volledige regels, de complete code en de geautomatiseerde portefeuille.