This is my first indicator that looks fairly effective. My goal is to reduce choppy trades and elongate hold times. The longer we can stay in the trend the better. This one was fun because it forced me to write and refine a universal trend indicator I can use to enhance already useful trend trading strategies. I will release the trend indicator separate as well so you can copy and paste into your own studies.
Most of my backtesting was done in futures /ES, /RTY, /NQ, /CL, /YM, /GC
Some things I have found while testing: Lower time frames benefit if you change the trend detection to aggressive. The higher time frames work much better with basic or turned off.
I am looking for criticism so I can get better at expressing my ideas into these systems.
Cheers!
-ZachC
The ADX Trend Strategy works pretty well without the enhancement. It should help to identify longer type trends.
Now we can change the settings to Basic
After the basic enhancement, the trend time frame is elongated to capture just a little more alpha.
I would also encourage anyone who can not short in their account to turn off the downtrend and short cover options. If you are in a short trade you could miss out on a long indicator.
Here is the code
Most of my backtesting was done in futures /ES, /RTY, /NQ, /CL, /YM, /GC
Some things I have found while testing: Lower time frames benefit if you change the trend detection to aggressive. The higher time frames work much better with basic or turned off.
I am looking for criticism so I can get better at expressing my ideas into these systems.
Cheers!
-ZachC
The ADX Trend Strategy works pretty well without the enhancement. It should help to identify longer type trends.
Now we can change the settings to Basic
After the basic enhancement, the trend time frame is elongated to capture just a little more alpha.
I would also encourage anyone who can not short in their account to turn off the downtrend and short cover options. If you are in a short trade you could miss out on a long indicator.
Here is the code
Rich (BB code):
#hint:<b>Use ADX as your Long and Short entry points</b>\nEnhanced with trend confirmation strat on entry and exits.
input length = 14;
input lag = 12;
input averageLength = 25;
input trendLevel = 20;
input maxLevel = 42.0;
input critLevel = 22.0;
input mult = 1.8;
input averageType = AverageType.SIMPLE;
input EnhancedLong = {default Off, Basic, Simple, Aggressive};
input EnhancedShort = {default Off, Basic, Simple, Aggressive};
def ma = MovingAverage(averageType, close, averageLength);
def adx = reference ADX(length = length);
plot movingAVG = ma;
# Trend Quality
# Author: ZachC on useThinkscript.com
# You can use the uptrend and downtrend indicators in addition to a positive signal
# OR
# Use the stay long indicator to ride out your bullish trend a little longer
# Use the stay short indicator to ride out your bullish trend a little longer
###
# Basic Trend Level, Crude but effective
##
# Simple Trend
# Bar 1 is greater then bar two or TQ is above 0
# Vice Versa for down trend
##
# Aggressive Trend
# The last 3 bars are in an up trend
# The last 3 bars are in a down trend
###
def trLong;
switch (EnhancedLong) {
case Basic:
trLong = TrendPeriods() == 1;
case Simple:
trLong = TrendQuality().TQ[0] > TrendQuality().TQ[1] or TrendQuality().TQ >= 0;
case Aggressive:
trLong = TrendQuality().TQ[0] > TrendQuality().TQ[1] and TrendQuality().TQ[1] > TrendQuality().TQ[2];
case Off:
trLong = TrendQuality().TQ;
}
def trShort;
switch (EnhancedShort) {
case Basic:
trShort = TrendPeriods() == 1;
case Simple:
trShort = TrendQuality().TQ[0] > TrendQuality().TQ[1] or TrendQuality().TQ >= 0;
case Aggressive:
trShort = TrendQuality().TQ[0] > TrendQuality().TQ[1] and TrendQuality().TQ[1] > TrendQuality().TQ[2];
case Off:
trShort = TrendQuality().TQ;
}
# 1st Long Setup ( Strong Uptrend )
# ADX First needs to cross above the Trend Level
# But it must be below the Max Level
# The last closing bar must be above the SMA
AddOrder(OrderType.BUY_TO_OPEN, adx crosses above trendLevel and
adx < maxLevel and
close > ma and trLong, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "StrongUptrend");
# 2nd Long Setup ( Typical Uptrend )
# ADX must be less then the Multiplyer times the lowest ADX value in the last 12 bars
# ADX must also cross above the critical level set 22
# The last closing bar must be above the SMA
AddOrder(OrderType.BUY_TO_OPEN, adx > mult * Lowest(adx, lag) and
adx crosses above critLevel and
close > ma, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "Uptrend");
# 1st Short Setup (Strong Down Trend)
# ADX first must cross above the trendlevel
# ADX must be less than the max level
# The last closing bar must be below the SMA
AddOrder(OrderType.SELL_TO_OPEN, adx crosses above trendLevel and
adx < maxLevel and
close < ma and trShort, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "StrongDowntrend");
# 2nd Short Setup ( Typical Downtrend )
# ADX is greater then the multiplyer of 1.8 times the lowest ADX in the last 12 bars
# ADX must cross above the critical level
# The last closing bar must be below the SMA
AddOrder(OrderType.SELL_TO_OPEN, adx > mult * Lowest(adx, lag) and
adx crosses above critLevel and
close < ma, tickcolor = GetColor(3), arrowcolor = GetColor(3), name = "Downtrend");
#Covering needs improvement
# Price closes below the SMA and TrendShort period selected above
AddOrder(OrderType.SELL_TO_CLOSE, Average(close) < ma and trLong, tickcolor = GetColor(4), arrowcolor = GetColor(4), name = "LongCover");
# Price closes above the SMA and TrendLong period selected above
AddOrder(OrderType.BUY_TO_CLOSE, Average(close) > ma and trShort, tickcolor = GetColor(5), arrowcolor = GetColor(5), name = "ShortCover");
Attachments
Last edited by a moderator: