jox51

Member
2019 Donor
VIP
The below indicator is a replica of the ADX system that Chris Moody coded for TradingView at the link below. Feel free to edit and use as you wish. He uses the Gann Swing Hi Low indicator, I used the PSAR indicator as an alternate. Some images attached below.

Code:
``````#
# This study attempts to replicate Chris Moody's ADX System for TOS. All credit goes to him. This study incorporates the GannHiLo study to determine the swing hi's and lows.

# Take a look at the video here where he explains this system.

# This study attempts to catch the beginning of a swing move in a trending underlying. What you want to do is waiting for crossovers of the DI+/DI- respectively while the ADX is beginning to Trend above 20 while the ParabolicSAR is in a supportive Swing High or Low. The buy/sell signals will alert you to this. Use your own discretion.

# When the ADX is over 40, the trend is exhausted and you should be looking at exiting your positions.

# Gann High Low
# Converted by theelderwand

input HPeriod= 13;
input LPeriod= 21;

def HLd = if close > SimpleMovingAvg(high, HPeriod)[1]
then 1
else (if close< SimpleMovingAvg(low, LPeriod)[1]
then -1
else 0);

def HLv = if HLd != 0 then HLd else 0;

plot HiLo = if HLv == -1
then SimpleMovingAvg(high, HPeriod)
else SimpleMovingAvg(low, LPeriod);

HiLo.AssignValueColor(if HLv==-1 then Color.Red else Color.Green);

#Below code is for ADX and DMI confirmation

input length = 14;
input averageType = AverageType.WILDERS;

def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
def ADX = MovingAverage(averageType, DX, length);

def sell = ADX > 20 && ADX > ADX[1] && "DI-" crosses above "DI+" && HLv==-1;

# Plot Signals
plot sellsignal = sell;
sellsignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellsignal.SetDefaultColor(Color.CYAN);
sellsignal.SetLineWeight(1);``````

https://tos.mx/PRaxsci
DMIMod code below

https://tos.mx/CUaFybK
Incorporated the GannHiLow study to stay true to the original system.

Thanks @BenTen for pointing me to the GannHiLo study on this site.

Last edited:

diazlaz

Well-known member
2019 Donor
VIP
Should we port the Gann Swing Hi Low indicator, If it hasn't already. Let me know if you think it's worth it?

jox51

Member
2019 Donor
VIP
I would say so, that way it remains true to the original system

jox51

Member
2019 Donor
VIP
Just updated the code to incorporate the Gann High Low study. Enjoy.

diazlaz

Well-known member
2019 Donor
VIP
Hi @jox51 -awesome ty! - the buy and sell plots are not plotting not sure if the HLv criteria is valid I changed the buy from <> to != and it started the buy signal, haven't seen a sell condition triggered yet. Have you compared GANN to the PSAR? Something I added to backlog to test. thanks for the conversion.

jox51

Member
2019 Donor
VIP
Tested it, and it appears to be working. I did a scan but not many buy signals show up.

Last edited: