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

trader_

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
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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

Screenshot 2024-03-25 020714.png
Code:
# ADX_Smoothed_Line_Agg
#
#

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);

#Smoothed Higher Agg ADX
def minutes = agg / 60000;
def bar = BarNumber();
def o = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0
        then ADX15
        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
AddLabel(showlabels, agg / 60000 + "m ADX: " + ADX15, dd.TakeValueColor());

#Bubbles
AddChartBubble(showbubble and
#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);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
425 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top