When the 15 bar channel is more than 60 points wide, the strategy places a buy stop one quarter up from the channel bottom, provided the MACD histogram is rising. The target is the channel midpoint and the stop is the channel bottom. It takes at most one trade per day and has not been backtested yet.
| positionSize Base contracts per trade | 3 |
| channelPeriod Donchian channel length | 15 |
| minChannelWidth Channel must be at least this many points wide | 60 |
| quadrantDivisor Entry line sits one quarter up from the channel bottom | 4 |
| targetDivisor Target sits at 1/targetDivisor of the channel (2 = midpoint) | 2 |
| lossMultiplier Order size multiplier after a losing trade | 2.5 |
| winDivisor Order size divisor after a winning trade | 1.5 |
| macdFast MACD fast length | 12 |
| macdSlow MACD slow length | 26 |
| macdSignalPeriod MACD signal length | 9 |
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.
// ============================================================ // Quadrant Channel // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long only // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false DEFPARAM PreloadBars = 50000 // --- Parameters --- positionSize = 3 // base contracts per trade channelPeriod = 15 // Donchian channel length minChannelWidth = 60 // channel must be at least this many points wide quadrantDivisor = 4 // entry line sits one quarter up from the channel bottom targetDivisor = 2 // target sits at 1/targetDivisor of the channel (2 = midpoint) lossMultiplier = 2.5 // order size multiplier after a losing trade winDivisor = 1.5 // order size divisor after a winning trade macdFast = 12 // MACD fast length macdSlow = 26 // MACD slow length macdSignalPeriod = 9 // MACD signal length // --- Indicators --- // Size cap as in the original: two losses in a row on top of the base size. maxOrderSize = lossMultiplier * lossMultiplier * positionSize + positionSize ONCE orderSize = positionSize ONCE bestProfit = 0 ONCE entryBlocked = 0 newDay = 0 IF Date <> Date[1] THEN newDay = 1 ENDIF // Daily reset: back to base size only when equity is at a new high. IF newDay THEN IF StrategyProfit > bestProfit THEN orderSize = positionSize bestProfit = StrategyProfit ENDIF entryBlocked = 0 ENDIF
42 more lines: the entry and exit rules.
Read this first
Questions
The code uses ProOrder with a buy stop entry, but it is untested and not compile checked. Backtest it first and consider removing the martingale sizing.
Nothing yet. The 60 point width filter is sized for a large index such as the DAX.
There is no drawdown figure yet. Because size starts at 3 contracts and rises after losses, the capital needed can grow quickly.
After any closed trade the system waits for the next day, which limits how often the martingale steps up in a single session.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.