MTF ADX?

H

hashy

Member
Does anyone know of a multi-time frame ADX script? From what I gather because ADX calls up another study (DMI) it isn't as simple as input Period = aggregationPeriod.DAY; or similar.

i.e., I want to be on a 1m chart but have an ADX indicator showing me ADX on 5m.

Thanks!
 
P

Pensar

Active member
VIP
@hashy Here is a multi-timeframe ADX -
Code:
# Multi-Timeframe ADX
# based on DMI indicator code by TD Ameritrade IP Company, Inc. (c) 2008-2020

declare lower;

input length = 14;
input averageType = AverageType.WILDERS;
input aggregation = aggregationperiod.FIVE_MIN;
def h = high(period = aggregation);
def l = low(period = aggregation);
def c = close(period = aggregation);

def hiDiff = h - h[1];
def loDiff = l[1] - l;

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(h, c, l), 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;
plot ADX = MovingAverage(averageType, DX, length);
     ADX.SetDefaultColor(GetColor(5));
 

Similar threads

Top