# The Holy Grail ADX Trading Setup
# Assembled by BenTen at useThinkScript.com
# This is NOT the Holy Grail! It was named that way by Linda Bradford Raschke and Larry Connors for its simplicity.
# You are free to use this code for personal use, and make derivative works from it.
# You are NOT GRANTED permission to use this code (or derivative works) for commercial
# purposes which includes and is not limited to selling, reselling, or packaging with
# other commercial indicators. Headers and attribution in this code should remain as provided,
# and any derivative works should extend the existing headers.
# Start SMA
input price = close;
input length = 20;
input displace = 0;
def SMA = Average(price[-displace], length);
def SMAbull = price > SMA;
def SMAbear = price < SMA;
# Start ADX
input ADXlength = 14;
input ADXaverageType = AverageType.WILDERS;
def ADX = DMI(ADXlength, ADXaverageType).ADX;
def ADXpower = ADX > 30;
def bullish = SMAbull and ADXpower;
def bearish = SMAbear and ADXpower;
AssignPriceColor(if bullish then Color.GREEN else if bearish then Color.RED else Color.WHITE);