This is a pair of trading systems that both work on the same premise. The only difference between them is that once system uses a differential (system#1) whilst the other system uses a coefficient (system#2) to measure rapid changes in price action. Although the example submitted here is optimised for EUR_USD M15 (Long only), the system is market agnostic and can be adapted for a selection of markets / asset classes. For quickness of illustration purposes I have included only the long version here which should be enough to demonstrate the premise; Due to the differences between bull and bear price action any short adaptationist should be forked with separate optimizations for the short side.
There exists a good probability of continuation of price action when the following pattern is found:
1. Short term average range / momentum is accelerating by a certain amount faster than long term average range / momentum (AKA increasing differential)
2. Short term moving average (AKA trend) is moving in the same direction as price action
For more information about the underlining entry system indicator see my indicator here:
https://www.prorealcode.com/prorealtime-indicators/range-coefficient/
This can be used to predict an increase in volatility.
Thorough and regular optimization is required. Current optimization here is for EUR_USD M15
wintarget = 43 // Clip target to maximum of x points
minTradeTime = 43 // stay in trade for at least x bars
mcShortPeriod = 5 // Short period momentum
rcShortPeriod = 4 // Short period average range
mcLongPeriod = 100 // Long period momentum
rcLongPeriod = 100 // Long period average range
mcThreshold = 0.1 // Momentum coef or dif threshold
rcThreshold = 0.9 // Range coef or dif threshold
maShortPeriod = 18 // Short term moving average
maLongPeriod = 53 // Long term moving average
This is not a complete “black box” trading system. There is no risk management or exception handling code. This back test is purely to demonstrate risk:reward and hit rate of the above premise. Open to all suggestions. For any questions please discuss in a forum topic.
System 1/ (differential system)
// ====================================== \\
// :: MDif-RDif
// Long Name : Momentum Differential and Range Differential Accelleration
// Version : v1.11
// Author : Maz @ prorealcode.com
// Date : 07-04-2017
// Contact : prtmaz at gmail dot com
// -------------------------------------- //
// ====================================== \\
// :: Optimizations --
// -------------------------------------- //
once optimization = 1 // 1 = EUR/USD M15
// Set to 0 for re-optimization and walk-forward
if optimization = 1 then
// Static Optimization for EUR/USD M15
// May 2015 - April 2017
wintarget = 43 // Clip target to maximum of x points
minTradeTime = 43 // stay in trade for at least x bars
// try also 27
mcShortPeriod = 5 // Short period momentum
rcShortPeriod = 4 // Short period average range
mcLongPeriod = 100 // Long period momentum
rcLongPeriod = 100 // Long period average range
mcThreshold = 2 // Momentum coefficient threshold
rcThreshold = 8.5 // Range coefficient threshold
maShortPeriod = 18 // Short term moving average
maLongPeriod = 53 // Long term moving average
// ( try also 150 / or 53 for 70% hit rate / or 51
elsif optimization = 2 then
// Insert your optimizations here
// wintarget = 43 // Clip target to maximum of x points
// minTradeTime = 43 // stay in trade for at least x bars
// ...
endif
// ====================================== \\
// :: Indicators --
// -------------------------------------- //
// Momentum Differential ============= \\
mShort = momentum[mcShortPeriod]
mLong = momentum[mcLongPeriod]
mc = max(abs(mShort) - abs(mLong), 0)
// ----------------------------------- //
// Range Differential ================= \\
r = abs(range)
arLong = average[max(1, rcLongPeriod)](r)
arShort = average[max(1, rcShortPeriod)](r)
rc = max(0, arShort - arLong)
// ----------------------------------- //
// General Indicators ================= \\
upBar = close > open
maShort = exponentialAverage[maShortPeriod](Close)
maLong = exponentialAverage[maLongPeriod](Close)
// ----------------------------------- //
// ====================================== \\
// :: Entry Logic
// -------------------------------------- //
// long entry rules (buy condition)
bc1 = not longOnMarket
bc1 = bc1 and (mc >= mcThreshold)
bc1 = bc1 and (rc >= rcThreshold)
bc1 = bc1 and upBar
bc1 = bc1 and maShort > maShort[1]
// long exit rules (exit long conditions)
le1 = longOnMarket
le1 = le1 and ( barIndex >= barIndexAtBuy + minTradeTime )
le1 = le1 and (maLong < maLong[4])
// short entry rule
// -- na --
// short exit rules
// -- na --
// ====================================== \\
// :: Execution Handlers
// -------------------------------------- //
if bc1 then
buy 1 shares at market
set target pprofit wintarget
barIndexAtBuy = barIndex
endif
if le1 and longOnMarket then
sell at market
endif
System 2/ (coefficient system)
// ====================================== \\
// :: M-R Dif.coef.long
// Long Name : Momentum and Range Coefficient Accelleration Long only
// Version : v1.11
// Author : Maz @ prorealcode.com
// Date : 07-04-2017
// Contact : prtmaz at gmail dot com
// -------------------------------------- //
// ====================================== \\
// :: Optimizations --
// -------------------------------------- //
once optimization = 1 // 1 = EUR/USD M15
// Set to 0 for re-optimization and walk-forward
if optimization = 1 then
// Static Optimization for EUR/USD M15
// May 2015 - April 2017
wintarget = 43 // Clip target to maximum of x points
minTradeTime = 43 // stay in trade for at least x bars
// try also 27
mcShortPeriod = 5 // Short period momentum
rcShortPeriod = 4 // Short period average range
mcLongPeriod = 100 // Long period momentum
rcLongPeriod = 100 // Long period average range
//mcThreshold = 0.1 // 0.5 // Momentum coefficient threshold
//rcThreshold = 0.9 // 1 // Range coefficient threshold
maShortPeriod = 18 // Short term moving average
maLongPeriod = 53 // Long term moving average
// ( try also 150 / or 53 for 70% hit rate / or 51
elsif optimization = 2 then
// Insert your optimizations here
// wintarget = 43 // Clip target to maximum of x points
// minTradeTime = 43 // stay in trade for at least x bars
// ...
endif
// ====================================== \\
// :: Indicators --
// -------------------------------------- //
// Momentum Coefficient ============= \\
mShort = momentum[mcShortPeriod]
mLong = momentum[mcLongPeriod]
mc = max(0, (abs(mShort) / abs(mLong)) -1)
// ----------------------------------- //
// Range Coefficient ================= \\
r = abs(range)
arLong = average[max(1, rcLongPeriod)](r)
arShort = average[max(1, rcShortPeriod)](r)
rc = max(0, (arShort / arLong) -1)
//rc = max(0, arShort - arLong)
// ----------------------------------- //
// General Indicators ================= \\
upBar = close > open
maShort = exponentialAverage[maShortPeriod](Close)
maLong = exponentialAverage[maLongPeriod](Close)
// ----------------------------------- //
// ====================================== \\
// :: Entry Logic
// -------------------------------------- //
// long entry rules (buy condition)
bc1 = not longOnMarket
bc1 = bc1 and (mc >= mcThreshold)
bc1 = bc1 and (rc >= rcThreshold)
bc1 = bc1 and upBar
bc1 = bc1 and maShort > maShort[1]
// long exit rules (exit long conditions)
le1 = longOnMarket
le1 = le1 and ( barIndex >= barIndexAtBuy + minTradeTime )
le1 = le1 and (maLong < maLong[4])
// short entry rule
// -- na --
// short exit rules
// -- na --
// ====================================== \\
// :: Execution Handlers
// -------------------------------------- //
if bc1 then
buy 1 shares at market
set target pprofit wintarget
barIndexAtBuy = barIndex
endif
if le1 and longOnMarket then
sell at market
endif