Go With The Momentum
Hi,
Here’s a nice simply strategy which uses price action as the entry criteria, and two filters to keep it out of major downturns as it is currently a long only strategy. Short side to be worked on next.
Works well on both 5 and 15 mins on the NASDAQ. My preference is higher timeframes, so will look to develop that side further.
Feedback and any suggested enhancements around the trailing stop most welcome. The Sunday trading is something I am investigating further to see why it is negative. Anyway, work in progress, I hope you enjoy.
Thanks,
S
//==========================================================================================================
// Code: TEST Go with the Momentum
// Version 1
// Index: NASDAQ
// TF: 5 min
// TZ: EU
// Spread: 3
// Notes: v1.1 Core strategy, Long only
// v1.2 Tested Trailing stops
// v1.3 Added $ Loss limit
// v1.4 Tested a 4th Close High criteria - poor performance
// v1.5 Added Momentum (optimised) Long Entry Filter
// v1.6 Added Moving Averages (optimised) Long Entry Filter
// v1.7 Day of week code to reduce drawdown
//
// Testing on both 5 mins and 15 mins for NADSDAQ
//==========================================================================================================
PxMomentum = Momentum>21
PositionSize = 1
slp = 140// * PositionSize
//=== Entry Filter ===
//Filter 1
Timeframe (60 minutes)
indicator11=average[100,8]
indicator21=average[110,8]
F1 = indicator11>indicator21
Timeframe (Default)
UpTrend = Close > Close[1] AND Close[1] > Close[2] AND Close[2] > Close[3]
// Conditions to enter positions
IF NOT LongOnMarket AND UpTrend AND PxMomentum AND opendayofweek <> 2 AND F1 THEN
BUY PositionSize CONTRACTS AT MARKET
ENDIF
//graph UpTrend
//===== Exit Methodology =====
myrsiM5=rsi[14](close)
//
if myrsiM5<30 and barindex-tradeindex>1 and longonmarket and close>positionprice then
sell at market
endif
if myrsiM5>70 and barindex-tradeindex>1 and shortonmarket and close<positionprice then
exitshort at market
endif
//===================================
DSD = 0
if DSD then
once openStrongLong = 0
once openStrongShort = 0
if (time <= 080000 or time >= 210000) then
openStrongLong = 0
openStrongShort = 0
endif
//detect strong direction for market open
once rangeOK = 30
once tradeMin = 2500
IF (time >= 080500) AND (time <= 080500 + tradeMin) AND ABS(close - open) > rangeOK THEN
IF close > open and close > open[1] THEN
openStrongLong = 1
openStrongShort = 0
ENDIF
IF close < open and close < open[1] THEN
openStrongLong = 0
openStrongShort = 1
ENDIF
ENDIF
once bollperiod = 20
once bollMAType = 1
once s = 2
bollMA = average[bollperiod, bollMAType](close)
STDDEV = STD[bollperiod]
bollUP = bollMA + s * STDDEV
bollDOWN = bollMA - s * STDDEV
IF bollUP = bollDOWN THEN
bollPercent = 50
ELSE
bollPercent = 100 * (close - bollDOWN) / (bollUP - bollDOWN)
ENDIF
once trendPeriod = 80
once trendPeriodResume = 10
once trendGap = 4
once trendResumeGap = 4
if not onmarket then
fullySupported = 0
fullyResisteded = 0
endif
//Market supported in the wrong direction
IF shortonmarket AND fullySupported = 0 AND summation[trendPeriod](bollPercent > 50) >= trendPeriod - trendGap THEN
fullySupported = 1
ENDIF
//Market pull back but continue to be supported
IF shortonmarket AND fullySupported = 1 AND bollPercent[trendPeriodResume + 1] < 0 AND summation[trendPeriodResume](bollPercent > 50) >= trendPeriodResume - trendResumeGap THEN
exitshort at market
ENDIF
//Market resisted in wrong direction
IF longonmarket AND fullyResisteded = 0 AND summation[trendPeriod](bollPercent < 50) >= trendPeriod - trendGap THEN
fullyResisteded = 1
ENDIF
//Market pull back but continue to be resisted
IF longonmarket AND fullyResisteded = 1 AND bollPercent[trendPeriodResume + 1] > 100 AND summation[trendPeriodResume](bollPercent < 50) >= trendPeriodResume - trendResumeGap THEN
sell at market
ENDIF
//Started real wrong direction
once strongTrend = 60
once strongPeriod = 4
once strongTrendGap = 2
IF shortonmarket and openStrongLong and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent > strongTrend) = strongPeriod - strongTrendGap then
exitshort at market
ENDIF
IF longonmarket and openStrongShort and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent < 100 - strongTrend) = strongPeriod - strongTrendGap then
sell at market
ENDIF
endif
//==== Stop Loss ====
Set Stop $Loss slp
Quick updated to line 33 in the code;
UpTrend = Close > Close[1] AND Close[1] > Close[2] AND Close[2] > Close[3] AND Close [4] > Close [5]