# Rolling periods for 1 min chart based on 15 min ADX-possible?

##### New member
Hello,

Problem: I am using a 1-minute and 15-minute chart. I use the ADX from the 15 min chart. I wonder if, instead of waiting for the next 15-minute bar to close, I could have a rolling 15-minute ADX on my 1-minute chart.

Does this make sense? I appreciate any guidance on this. Thanks!

Hello,

Problem: I am using a 1-minute and 15-minute chart. I use the ADX from the 15 min chart. I wonder if, instead of waiting for the next 15-minute bar to close, I could have a rolling 15-minute ADX on my 1-minute chart.

Does this make sense? I appreciate any guidance on this. Thanks!
adjust the length to be 15x bigger

Hello,

Problem: I am using a 1-minute and 15-minute chart. I use the ADX from the 15 min chart. I wonder if, instead of waiting for the next 15-minute bar to close, I could have a rolling 15-minute ADX on my 1-minute chart.

Does this make sense? I appreciate any guidance on this. Thanks!

The following is a 15m ADX plotted on a 1m chart. The 15m ADX line on the 1m chart is smoothed to approximate the ADX displayed on a 15m chart.
This code can also be moved to the upper price panel as shown in the image

Code:
#
#

declare lower;

input showonexpansion       = no;
input showlabels            = yes;
input showbubble            = yes;
input showverticals         = yes;
input vertical_plot_limiter = 2;
input agg                   = AggregationPeriod.FIFTEEN_MIN;
input length                = 14;
input averageType           = AverageType.WILDERS;

def hiDiff = high(period = agg) - high(period = agg)[1];
def loDiff = low(period = agg)[1] - low(period = agg);

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(period = agg), close(period = agg), low(period = agg)), 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 ADX15 = MovingAverage(averageType, DX, length);

def minutes = agg / 60000;
def bar = BarNumber();
def o = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0
else o[1];

def x   = (if o != o[1] then x[1] + 1 else x[1]);
def cc =  if  x != x[1] then o else Double.NaN;
def ccextend = if IsNaN(close) then ccextend[1] else if  x != x[1] then o else ccextend[1];

def last = HighestAll(if IsNaN(cc[-1]) and !IsNaN(cc) then BarNumber() else Double.NaN);
def count = if x != x[1] then count[1] + 1 else count[1];
def cond  = HighestAll(count) - count + 1;

plot dd = if showonexpansion then if !IsNaN(close) then Double.NaN else ccextend else cc;
dd.EnableApproximation();

#Labels

#Bubbles
#cond[1] == 2 and cond == 1
cond == 1,  cc, ADX15, Color.GRAY, no);

#Verticals
input begin   = 0930;
def chartAgg  = GetAggregationPeriod();
def barSeq    = if SecondsTillTime(begin) == 0 and
SecondsFromTime(begin) == 0
then 0
else barSeq[1] + 1;
def barvertical = barSeq;
def hour = Floor(((9 * 60 + 30) + (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000) / 60);
def min  = (GetTime() - RegularTradingStart(GetYYYYMMDD())) / 60000 - ((hour - 9) * 60 + 30) + 60;
AddVerticalLine(showverticals and BarNumber() >= HighestAll(last) - vertical_plot_limiter and (barvertical) % (minutes / (GetAggregationPeriod() / 60000)) == 0, hour + ":" + min , color = Color.WHITE, stroke = Curve.FIRM);

87k+ Posts
425 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?