Price has to sit on the right side of four moving averages while ADX, Momentum, Williams %R and Stochastic all agree on direction. The actual entry fires on the bar where ADX(10) crosses one of a set of fixed levels. This version has not been backtested yet, so no results are published.
| positionSize Contracts per trade | 1 |
| fastPeriod Fast EMA, price must be on the right side of it | 8 |
| midPeriod Weighted MA, price must be on the right side of it | 34 |
| slopePeriod Weighted MA whose slope sets the trend direction | 150 |
| temaPeriod TEMA used for price position and slope | 15 |
| trendPeriod Long-term EMA trend filter | 200 |
| momentumPeriod Momentum must be rising (long) or falling (short) | 6 |
| fastAdxPeriod Short ADX that must not be falling | 6 |
| diPeriod DI+ / DI- length | 10 |
| adxPeriod Main ADX length | 10 |
| adxThreshold Main ADX must be above this | 18 |
| williamsPeriod Williams %R length | 40 |
| williamsMidLevel Williams %R side that separates bulls from bears | -50 |
| stochPeriod Stochastic %K length | 8 |
| stochSmooth Stochastic smoothing | 3 |
| stochLookback Stochastic compared with its value this many bars ago | 3 |
| closesAbovePeriod Last closes that must sit above the fast EMA (long) | 2 |
| adxLevelA ADX cross levels that can trigger an entry | 17 |
| adxLevelB ADX cross levels that can trigger an entry | 20 |
| adxLevelC ADX cross levels that can trigger an entry | 22 |
| adxLevelD ADX cross levels that can trigger an entry | 24 |
| adxLevelE ADX cross levels that can trigger an entry | 26 |
| adxLevelF ADX cross levels that can trigger an entry | 28 |
| adxLevelG ADX cross levels that can trigger an entry | 30 |
| stopLossPoints Protective stop | 30 |
| takeProfitPoints Profit target | 120 |
| ladderRungs Number of breakeven ladder steps | 25 |
| firstTriggerPips Profit that arms the first ladder step | 10 |
| firstLockPips Profit locked by the first step | 5 |
| secondTriggerPips Profit that arms the second step | 15 |
| ladderStepPips Spacing of every later step | 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.
// ============================================================ // ADX Momentum EMA // ProRealAlgos Strategy Library | prorealalgos.com // Type: Trend // Direction: Long & short // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false DEFPARAM PreloadBars = 50000 // --- Parameters --- positionSize = 1 // contracts per trade fastPeriod = 8 // fast EMA, price must be on the right side of it midPeriod = 34 // weighted MA, price must be on the right side of it slopePeriod = 150 // weighted MA whose slope sets the trend direction temaPeriod = 15 // TEMA used for price position and slope trendPeriod = 200 // long-term EMA trend filter momentumPeriod = 6 // momentum must be rising (long) or falling (short) fastAdxPeriod = 6 // short ADX that must not be falling diPeriod = 10 // DI+ / DI- length adxPeriod = 10 // main ADX length adxThreshold = 18 // main ADX must be above this williamsPeriod = 40 // Williams %R length williamsMidLevel = -50 // Williams %R side that separates bulls from bears stochPeriod = 8 // Stochastic %K length stochSmooth = 3 // Stochastic smoothing stochLookback = 3 // Stochastic compared with its value this many bars ago closesAbovePeriod = 2 // last closes that must sit above the fast EMA (long) adxLevelA = 17 // ADX cross levels that can trigger an entry adxLevelB = 20 adxLevelC = 22 adxLevelD = 24 adxLevelE = 26 adxLevelF = 28 adxLevelG = 30 stopLossPoints = 30 // protective stop takeProfitPoints = 120 // profit target ladderRungs = 25 // number of breakeven ladder steps firstTriggerPips = 10 // profit that arms the first ladder step firstLockPips = 5 // profit locked by the first step secondTriggerPips = 15 // profit that arms the second step ladderStepPips = 10 // spacing of every later step // --- Indicators --- fastMA = ExponentialAverage[fastPeriod](close) midMA = WeightedAverage[midPeriod](close) slopeMA = WeightedAverage[slopePeriod](close) temaValue = TEMA[temaPeriod](close) trendMA = ExponentialAverage[trendPeriod](close) momentumValue = Momentum[momentumPeriod](close) fastAdx = ADX[fastAdxPeriod] plusDI = DIplus[diPeriod](close) minusDI = DIminus[diPeriod](close) adxValue = ADX[adxPeriod] williamsValue = Williams[williamsPeriod](close) stochK = Stochastic[stochPeriod, stochSmooth](close) aboveFast = fastMA < close belowFast = fastMA > close aboveMid = midMA < close belowMid = midMA > close aboveTrend = trendMA < close belowTrend = trendMA > close aboveTema = temaValue < close belowTema = temaValue > close slopeUp = slopeMA > slopeMA[1] slopeDown = slopeMA < slopeMA[1] temaUp = temaValue > temaValue[1] temaDown = temaValue < temaValue[1] williamsBull = williamsValue > williamsMidLevel williamsBear = williamsValue < williamsMidLevel stochRising = stochK > stochK[stochLookback] stochFalling = stochK < stochK[stochLookback]
50 more lines: the entry and exit rules.
Read this first
Questions
The code is written for ProOrder automatic trading, but it has not been compile checked or backtested yet. Run it in ProBacktest on your own market before going live.
None so far. The page will show results per instrument once backtests are done.
Default size is 1 contract with a 30 point stop, but without a backtest there is no drawdown figure to size capital from. Treat any live use as untested.
The other filters only describe the trend state. The ADX(10) cross above 17, 20, 22, 24, 26, 28 or 30 (longs) gives a single bar where trend strength is picking up, so the trade has a clear trigger.
Related
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.