Repaints The Multi-10x MTF Labels Indicator for ThinkorSwim

Repaints
@billgt @TomRite and anyone else trying to get the 10x bars indicator to actually paint bars (NOT the label showing the color of the current bar), here is the code. It will work on any time frame you have on your chart (just like any indicator). I use it on 78 min, I know someone wanted to see it on 10-day aggregation period. 10 days is not possible on TOS since it won't allow 65 hours (10x6.5h). The closest aggregation period would be a week or a month. The indicator works best with extended hours turned OFF (John teaches to turn those off for all equities and only leave them on for futures).

Please note that the yellow bars indicate that the momentum in the current trend up or down has weakened and the trend may (but does not have to) reverse. That's where you'd use smaller time frames to guide your decision (e.g. 2h and less is red, all higher time frames are yellow--this may be the beginning of a down trend). The opposite is true: for instance 2h and less is yellow and slightly red but all higher time frames are green. This is a "buy the dip" opportunity (as we've seen in AAPL between 11/20 and now). This is at least my understanding of the concept. If anyone has taken John's 10x on steroids class, please share any details here.

Anyway, here is the indicator. Let me know if you want a shareable link for easy import into TOS.

Code:
#The 10x bars
#sierioiza, credit John F. Carter from Simpler Trading
#11/20/2019

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

declare upper;
declare once_per_bar;

AssignPriceColor(if "DI+" > "DI-" and ADX > 20 then Color.GREEN
  else if "DI+" < "DI-" and ADX > 20 then Color.RED
  else Color.YELLOW);
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

@billgt Please use the above code as the 10x bars indicator. Please post back when you have added the volume dot indication to it (you can read my second to last post about the parameters of the volume dot). I know everyone would highly appreciate your help!
 
Here is the code to paint the bars with the volume dot. I started this in my own script before I saw your last post so the header is slightly different. I gave credit to @sierioiza and @tomsk for their code that was used and / or modified here. If you want to change the header back or to something different please feel free. I am new here so not sure the appropriate protocol. So again, feel free to change it however you think is most appropriate.

Code:
#Visual DMI Bar Paint and Volume Dot
#Last Updated on Wednesday, November 27 2019 at 04:18:47 PM
#
#CREDITS
# John Carter's 10x bars, @sierioiza, @billgt, @tomsk
#
#CHANGELOG
# EXAMPLE 2019.11.25 1.0 @billgt - Example

#DESCRIPTION
# We can see the DMI / ADX calculation used painted on the price
# bars for the current time frame.  The first part of this code was
# written by @sierioiza and just copied here to add the volume dot.
# I copied some code for generating dots for some other Study from a post by @tomsk and the modified to get the volume dots.
# A blue dot is plotted on bars that have a volume greater than input volumeGreaterPercent of the moving average for the timeframe of
# input volumeLength.

#INSTRUCTIONS
# Recommended to add it and use the defaults
# If you want to see volume dots on the yellow (neutral) bars too then change the plotVolumeDotOnNeutral to yes.


input length = 14;
input averageType = AverageType.WILDERS;
input volumeLength = 20;
input volumeFactor = 1;
input plotVolumeDotOnNeutral = no;
input volumeGreaterPercent = 50;

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

declare upper;
declare once_per_bar;
def priceColor = if "DI+" > "DI-" and ADX > 20 then 0
  else if "DI+" < "DI-" and ADX > 20 then 1
  else 2;
AssignPriceColor(if pricecolor == 0 then Color.GREEN
  else if priceColor == 1 then Color.RED
  else Color.YELLOW);



#Get moving average of volume
def volAvg = MovingAverage(length = volumeLength,data = volume);
#Calculate middle of bar
def volDotLocation = volumeFactor * MidBodyVal();
#calculate 50% increase in average volume
def vol50IncLevel = volAvg * (1 + (volumeGreaterPercent / 100));
#if current volume is greater than the configured length MA of the volume and the price color is not yellow (neutral) or configured to plot on yellow bars (neutral) then plot volume dot
plot volDot = if volume >= vol50IncLevel and (priceColor != 2 or plotVolumeDotOnNeutral) then volDotLocation else Double.NaN;
volDot.SetStyle(Curve.POINTS);
volDot.SetDefaultColor(Color.CYAN);
volDot.SetLineWeight(2);
#AssignPriceColor(Color.BLUE);
 
@billgt this is great! how can you tell in the code if the moving average used for volume bars is simple moving average or some other type? right now it only says "MovingAverage"
 
@billgt Its using WILDERS - defined in the code above as

input averageType = AverageType.WILDERS;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
 
Ok. Here is the Visual DMI MTF with the Buy / Sell Signal on a single time frame. I also found the SQZ MTF on this site already - https://usethinkscript.com/threads/multiple-time-frame-mtf-squeeze-indicator-for-thinkorswim.350/ . The one I had found before was a change to this to show single dots below. I thought that was all that was here. So that was already done for me.

I did not incorporate @tomsk 's change because this just works and I don't have time right now. I have no doubt it is cleaner so if someone wants to change this and do it his way please do and post it. I am trying to get this all ready to go and study up on it before the Futures market opens tomorrow. There looks to be a great setup on /NQ. The market went down on Friday but long term everything still looks up and the shorter time frames are already turning. There are buy signals on almost all the mid term time frames for /NQ. So I am going to start buying contracts this Sunday night and then wait for the market open to confirm and then buy more if it does indeed go up.

I would still like to take the Simpler Trading class and live trade with them on this. I am probably going to inquire as to whether they would swap out indicators for the price of the class like the squeeze pro and vodoo lines or something like that. I have followed John's trading style for pivots, Reversion to mean, GAP play, and squeeze with pretty good success. I think this is the next evolution. Too soon to say if any of it will work over the long term.

If anyone takes the class let us know how it is and how your trading goes after it. If you haven't done the GAP play I highly recommend it. Buy John's book for $30 and read that chapter alone. I have traded it for several months and it has only failed 1-2 times. It is gold at least for now. It is so good that I am thinking of doing that only and risking 3-5% of my portfolio each time instead of the 1% I am doing now.

Happy trading!



Code:
#Visual DMI Single (The 10x Bars) MTF Labels for ThinkorSwim V1.7
#Last Updated on Saturday, November 30 2019 at 04:25:32 PM
#
#CREDITS
# John Carter's 10x bars, @sierioiza, @tomsk, @horserider, @markos, @billgt
#
#CHANGELOG
# 2019.11.25 1.0 Sample - Sample
#
#DESCRIPTION
# Same as Visual DMI but with one time frame and an input
#
#
#INSTRUCTIONS
# Add this stud to the chart as many times as you want to show timeframes for
# It will automatically show just the ones that are equal or higher than the timeframe of your chart
#


#INPUTS
input length = 14; #DI+- length
input timeFrame = AggregationPeriod.MIN;
#input timeFrame = { "1 min", "5 min", default "15 min", "30 min", "60 min", "4 hours"};;
input lengthBSS = 21;
input adxlength = 20; #ADX sideways length
input averageType = AverageType.WILDERS;
input showlabels = yes; #show labels



#CORE
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
DefineGlobalColor("Neutral", Color.YELLOW);


#TIMEFRAME CHECK
def currentTimeFrame = getAggregationPeriod();
#assert(currentTimeFrame == AggregationPeriod.MIN, "ERROR: timeFrame needs to be 1 minute");

#LABELS
#AddLabel(showlabels, "10X System V1.7", COLOR.CYAN);




def tf = if currentTimeFrame <= timeFrame then timeFrame else currentTimeFrame;
def tfAvailable = currentTimeFrame <= timeFrame;
def hiDiffM5 = high(period = tf) - high(period = tf)[1];
def loDiffM5 = low(period = tf)[1] - low(period = tf);

def plusDMM5 = if hiDiffM5 > loDiffM5 and hiDiffM5 > 0 then hiDiffM5 else 0;
def minusDMM5 =  if loDiffM5 > hiDiffM5 and loDiffM5 > 0 then loDiffM5 else 0;

def ATRM5 = MovingAverage(averageType, TrueRange(high(period = tf), close(period = tf), low(period = tf)), length);
def "DI+M5" = 100 * MovingAverage(averageType, plusDMM5, length) / ATRM5;
def "DI-M5" = 100 * MovingAverage(averageType, minusDMM5, length) / ATRM5;

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

def bullishM5 = ("DI+M5" > "DI-M5") and (ADXM5 > adxlength);
def bearishM5 = ("DI+M5" < "DI-M5") and (ADXM5 > adxlength);
def sidewaysM5 = (ADXM5 < adxlength);

def sStateM5 =  if !tfAvailable then Double.NaN else if bullishM5 then 100 else if bearishM5 then -100 else 0;
def sPOSM5 = if IsNan(sStateM5) then 0 else bullishM5;
def sNEGM5 = if IsNan(sStateM5) then 0 else bearishM5;
def sSIDM5 = if IsNan(sStateM5) then 0 else if sPOSM5 or sNEGM5 then 0 else sidewaysM5;

AddLabel(showlabels and tfAvailable, if timeFrame == aggregationPeriod.MONTH then "M"
    else
    if timeFrame == aggregationPeriod.WEEK then "W"
    else
    if timeFrame == aggregationPeriod.FOUR_DAYS then "4D"
    else
    if timeFrame == aggregationPeriod.THREE_DAYS then "3D"
    else
    if timeFrame == aggregationPeriod.TWO_DAYS then "2D"
    else
    if timeFrame == aggregationPeriod.DAY then "D"
    else
    if timeFrame == aggregationPeriod.FOUR_HOURS then "4H"
    else
    if timeFrame == aggregationPeriod.TWO_HOURS then "2H"
    else
    if timeFrame == aggregationPeriod.HOUR then "60m"
    else
    if timeFrame == aggregationPeriod.THIRTY_MIN then "30m"
    else
    if timeFrame == aggregationPeriod.TWENTY_MIN then "20m"
    else
    if timeFrame == aggregationPeriod.FIFTEEN_MIN then "15m"
    else
    if timeFrame == aggregationPeriod.TEN_MIN then "10m"
    else
    if timeFrame == aggregationPeriod.FIVE_MIN then "5m"
    else
    if timeFrame == aggregationPeriod.FOUR_MIN then "4m"
    else
    if timeFrame  == aggregationPeriod.THREE_MIN then "3m"
    else
    if timeFrame == aggregationPeriod.TWO_MIN then "2m"
    else
    if timeFrame  == aggregationPeriod.MIN then "1m"
    else "", if IsNan(sStateM5) then COLOR.DARK_GRAY else
 if sStateM5 == 100 then GlobalColor("Bullish") else
 if sStateM5 == -100 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));




def highestBarIndex = GetMaxValueOffset(high(period=tf),lengthBSS);
def lowOfHighBar = GetValue(low(period=tf),highestBarIndex,lengthBSS);
def highOfHighBar = GetValue(high(period=tf),highestBarIndex,lengthBSS);
#If the current bar is the highest then we won't be painting the down arrow here and we need to reset that the arrow can be painted.  Else if the arrow hasn't been painted yet and this bar closes below the low of the highest high then set it to paint else set this PaintArrow to then last bars paint arrow.

#ArrowDn

def PaintArrowDown = if highestBarIndex == 0 then 0 else if PaintArrowDown[1] == 0 and close(period = tf) < lowOfHighBar then 1 else PaintArrowDown[1];

def ArrowDn = if PaintArrowDown[1] == 0 and PaintArrowDown == 1 then 1 else 0;


#PLOT UP ARROWS

#Get the lowest low in the last x number of bars specified by length
#Get the high of that bar
def lowestBarIndex = GetMinValueOffset(low(period=tf),lengthBSS);
def highOfLowBar = GetValue(high(period=tf),lowestBarIndex, lengthBSS);
def lowOfLowBar = GetValue(low(period=tf),lowestBarIndex, lengthBSS);

#If the current bar is the lowest then we haven't painted the up arrow for this low so set it to zero.  Else if the arrow hasn't been painted yet for this low and this bar closes above the high of the lowest low then set it as having been painted (1) else if a new low within the 20 is found at this bar then set painted to 0 because we haven't painted this bar yet else set this PaintArrowUp to the last bars paint arrow high which will indicate whether we have already painted or not.


def paintArrowUp = if lowestBarIndex == 0 then 0 else if PaintArrowUp[1] == 0 and close(period=tf) > highOfLowBar then 1 else PaintArrowUp[1];

def foundNewLow = if lowOfLowBar != lowOfLowBar[1] then if foundNewLow[1] == 1 then 0 else 1 else if foundNewLow[1] == 1 then 1 else foundNewLow[1];

def ArrowUp = if paintArrowUp[1] == 0 and paintArrowUp == 1 then low(period = tf) - (2*TickSize()) else 0;

#plot PaintArrowUpPlot = PaintArrowUp;

def bssFinal = if ArrowUp > 0 and ArrowDn > 0 then 3 else if ArrowUp > 0 then 1 else if ArrowDn > 0 then 2 else 0;
#def BSS5Min = if availableM5 then BuySS( lengthBSS, aM5) else 0;
AddLabel(showlabels and tfAvailable and bssFinal > 0,if bssFinal == 3 then "BS" else if bssFinal == 2 then "S" else "B",COLOR.LIGHT_GRAY);



# END OF Visual DMI (The 10x Bars) MTF Labels for ThinkorSwim
 
I am working on the buy / sell signals now for the Multi time frame visual DMI indicator. Two things I found out that someone here might shed some light on.

1. There is no way to reference a custom study from within another study. The only studies that you can reference are ones supplied by TOS. A Hahn tech article seems to confirm this. If anyone here knows differently or how to do this please let me know.
2. You can embed a script inside a TOS study but ... if you try to use multiple time frames inside of that script it will produce unreliable results. I tried it and it works but unreliably. The only confirmation I could find of this was a Hahn tech article again in which he says it is a limitation of the script command that he confirmed with a tech support case to TOS.

Without being able to do either of these the code for the multi time frame DMI with the buy signal for each timeframe is going to get extremely large and hard to manage. I was looking at the instructions for installing other retail studies and it became clear to me that these other multi time frame studies are not putting all of their code for all time frames inside one giant study. Instead they are putting the study on the chart multiple times and setting an input to the time frame. This would essentially allow us to write the code one time like a function and just pass parameters into it. I am going to re-write both this indicator and the multi time frame squeeze to do it this way before I put back in my code to do the Buy / Sell signals on the MTFs.

The one thing we will give up is the overall stats. Since there won't be one giant indicator with all the code it won't be able to calculate the totals. For me losing that functionality is worth it to not have a study with 1000 lines of code in it.

Let me know if I am missing something. This is how other retail studies are doing it the best I can tell.

Thanks!

@billgt That is exactly right. You cannot embed a custom study from another custom study. To do so you would have to replicate the required code and then integrate this with your custom study.

I have previously alerted this community that you cannot utilize the script() function for MTF studies utilizing secondary aggregation. You can read about it on this thread here

https://usethinkscript.com/threads/...dies-utilizing-script-for-secondary-aggs.969/
 
@billgt Nice! Quick question: what does it mean when the label shows BS? I understand B is for buy, S is for sell. What is BS for? Also, how do I assign CYAN color to label B only, and LIGHT_ORANGE to label S only? It seems that the same color is assigned to B, S, and BS right now.
 
Last edited:
I'm glad it's working now. If you have any tips on how John uses this set of tools, please share here. One thing I learned so far is that reversal arrows in a strong trend indicate reversion to the mean. For example, when 10x bars are green, you get reversal arrow down--that's when you need to wait until the price gets back to the mean (use Keltner channel length 21 with factors 1, 2, and 3), and then buy it there. The opposite is true if you are trying to go short--wait until it gets back up to the mean (or one of the closest deviations) and then go short. John also likes to use this set of tools on 30 min, (sometimes 39 min,) 78 min, 195 min, and daily charts. I find that reversal arrows and also 10x bars colors work best on 30 minutes and higher time frames. Shorter time frames will give you temporary dips/spikes signals and early heads up at best. 8/21 EMA crossover together with 10x bars is very helpful, too. Please share if you know/learned more. I think everyone will appreciate it.
 
Can anyone comment out or hide the candle coloring on the volume dots indicator so I can use it with other indicators that color candles in a different way? The volume dots are really nice but I am still experimenting with different studies that color the candles in other ways. Thanks!
 
if I have enough requests and anyone is interested, I can release a version that you can select up to 6 aggregation periods directly as an input, the benefit, it will allow you to display a higher aggregation than a 1 minute since you need to have the lowest aggregation chart active. if you don't trade a 1 minute, then you can select your lowest such as a 5 minute, then you can move to a 5 minute, 10, 30, 1HR, 4HR for input of the aggregation period directly as parameter. allowing you to move up from the default 1 MIN requirement to 5 MIN chart.

this style of indicator was really to allow a state view of all aggregation periods in one chart for regime analysis.
Hello Diazlaz,

I found your V1.6 of the code for the MTF squeeze and it works great! I have been trying to find something like and it helped me with my trading today. I did notice it slowed my charts a lot, it is taking about 5-10 seconds to switch between tickers. It seems when I remove it, it returns to normal speed but I really prefer to continue using it. Is it possible to make edits to the code so my chart speeds aren't impacted? I apologize in advance if that seems like a silly question, I am a coding and TOS novice :)
 
@Delukious The only way to speed your chart paints up would be to reduce the number of calculations and labels from 18 to a lower amount... I had to do the same thing with the Madrid_Moving_Average_Ribbons Study that painted 20 MA's... I reduced the number by half...
 
@Delukious The only way to speed your chart paints up would be to reduce the number of calculations and labels from 18 to a lower amount... I had to do the same thing with the Madrid_Moving_Average_Ribbons Study that painted 20 MA's... I reduced the number by half...
Thank you so much for the quick response! How would I do that exactly? I tried deleting the lines that have the smaller time frames but it doesnt seem to be working. I truly appreciate your help!
 
@Delukious Below is an example of a scaled down version of the v1.6 script which on has 10 timeframes... In order to speed the script up the code for the extra timeframes had to be removed because regardless of whether the labels get painted all of the associated calculations had to be made anyway... In addition to removed some of the timeframes any references to deleted variables also needed to be removed... As I said, just an example but it works...

Ruby:
#Visual DMI (The 10x Bars) MTF Labels for ThinkorSwim V1.6
#Last Updated on Monday, November 25 2019 at 09:51:52 PM
#
#CREDITS
# John Carter's 10x bars, @sierioiza, @tomsk, @horserider, @markos
#
#CHANGELOG
# 2019.11.25 1.0 @diazlaz - Updated Port
# 2019.11.25 1.1 @diazlaz - Added Month Time frame
# 2019.11.25 1.2 @diazlaz - Added additional timecheck on chart and instructions
# 2019.11.25 1.2 @diazlaz - Added additional aggregation periods (18 total)
# 2019.11.25 1.2 @diazlaz - Added additional periods 4MIN, 20MIN, 2DAYS, 4DAYS
# 2019.11.25 1.3 @diazlaz - Added adxlength and showlabels inputs
# 2019.11.25 1.4 @diazlaz - Added states and stats labels
# 2019.11.25 1.5 @diazlaz - Added fix for NaN when data is not available
#                           such as monthly for UBER due to recent IPO.
#                           colors Label as Dark Gray when no data is available.
#                           handles count of stats when error is encountered.
# 2019.11.25 1.6 @diazlaz - Added inputs for label display all aggregation periods
#                           default display all set to yes.
#                           Note:
#                            STATS still calc all periods. if this is a ask to filter
#                            based on displayed aggregation periods please let me know
#                            and will incorporate this request.
#
#2020.12.30 1.6a @rad14733 - reduced the number of timeframes to improve performance
#
#DESCRIPTION
# For TSLA, we can see the 10X bars across various time frames,
# from the Weekly down to the 1-minute chart.  We can see at a
# glance that there is strong GREEN momentum across most time frames.
# Any short-term red sets up a buying opportunity back in the direction
# of the longer-term greens and vice versa.
#
#
#INSTRUCTIONS
# Set timeframe charts to 1 minute and 30 days.
#
#

#INPUTS
input length = 14; #DI+- length
input adxlength = 20; #ADX sideways length
input averageType = AverageType.WILDERS;
input showlabels = yes; #show labels
input showstats = yes; #show stats

input show1MIN = yes; #show ONE MINUTE label
input show3MIN = yes; #show THREE MINUTES label
input show5MIN = yes; #show FIVE MINUTES label
input show15MIN = yes; #show FIFTEEN MINUTES label
input show1HOUR = yes; #show HOUR label
input show4HOUR = yes; #show FOUR HOURS label
input show1DAY = yes; #show ONE DAY label
input show3DAY = yes; #show THREE DAYS label
input showWEEK = yes; #show ONE WEEK label
input showMONTH = yes; #show ONE MONTH label

#CORE
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
DefineGlobalColor("Neutral", Color.YELLOW);

#TIMEFRAME CHECK
def currentTimeFrame = getAggregationPeriod();
assert(currentTimeFrame == AggregationPeriod.MIN, "ERROR: timeFrame needs to be 1 minute");

#LABELS
AddLabel(showlabels, "10X System V1.6", COLOR.CYAN);


# AGGREGATION 1 - ONE MINUTE

def aM1 = aggregationPeriod.MIN;
def hiDiffM1 = high(period = aM1) - high(period = aM1)[1];
def loDiffM1 = low(period = aM1)[1] - low(period = aM1);

def plusDMM1 = if hiDiffM1 > loDiffM1 and hiDiffM1 > 0 then hiDiffM1 else 0;
def minusDMM1 =  if loDiffM1 > hiDiffM1 and loDiffM1 > 0 then loDiffM1 else 0;

def ATRM1 = MovingAverage(averageType, TrueRange(high(period = aM1), close(period = aM1), low(period = aM1)), length);
def "DI+M1" = 100 * MovingAverage(averageType, plusDMM1, length) / ATRM1;
def "DI-M1" = 100 * MovingAverage(averageType, minusDMM1, length) / ATRM1;

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

def bullishM1 = ("DI+M1" > "DI-M1") and (ADXM1 > adxlength);
def bearishM1 = ("DI+M1" < "DI-M1") and (ADXM1 > adxlength);
def sidewaysM1 = (ADXM1 < adxlength);

def sStateM1 = if bullishM1 then 100 else if bearishM1 then -100 else 0;
def sPOSM1 = if IsNan(sStateM1) then 0 else bullishM1;
def sNEGM1 = if IsNan(sStateM1) then 0 else bearishM1;
def sSIDM1 = if IsNan(sStateM1) then 0 else if sPOSM1 or sNEGM1 then 0 else sidewaysM1;

AddLabel(showlabels and show1MIN, "1MIN", if IsNan(sStateM1) then COLOR.DARK_GRAY else
if sStateM1 == 100 then GlobalColor("Bullish") else
if sStateM1 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 3 - THREE MINUTES

def aM3 = aggregationPeriod.THREE_MIN;
def hiDiffM3 = high(period = aM3) - high(period = aM3)[1];
def loDiffM3 = low(period = aM3)[1] - low(period = aM3);

def plusDMM3 = if hiDiffM3 > loDiffM3 and hiDiffM3 > 0 then hiDiffM3 else 0;
def minusDMM3 =  if loDiffM3 > hiDiffM3 and loDiffM3 > 0 then loDiffM3 else 0;

def ATRM3 = MovingAverage(averageType, TrueRange(high(period = aM3), close(period = aM3), low(period = aM3)), length);
def "DI+M3" = 100 * MovingAverage(averageType, plusDMM3, length) / ATRM3;
def "DI-M3" = 100 * MovingAverage(averageType, minusDMM3, length) / ATRM3;

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

def bullishM3 = ("DI+M3" > "DI-M3") and (ADXM3 > adxlength);
def bearishM3 = ("DI+M3" < "DI-M3") and (ADXM3 > adxlength);
def sidewaysM3 = (ADXM3 < adxlength);

def sStateM3 = if bullishM3 then 100 else if bearishM3 then -100 else 0;
def sPOSM3 = if IsNan(sStateM3) then 0 else bullishM3;
def sNEGM3 = if IsNan(sStateM3) then 0 else bearishM3;
def sSIDM3 = if IsNan(sStateM3) then 0 else if sPOSM3 or sNEGM3 then 0 else sidewaysM3;

AddLabel(showlabels and show3MIN, "3MIN", if IsNan(sStateM3) then COLOR.DARK_GRAY else
if sStateM3 == 100 then GlobalColor("Bullish") else
if sStateM3 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 5 - FIVE MINUTES

def aM5 = aggregationPeriod.FIVE_MIN;
def hiDiffM5 = high(period = aM5) - high(period = aM5)[1];
def loDiffM5 = low(period = aM5)[1] - low(period = aM5);

def plusDMM5 = if hiDiffM5 > loDiffM5 and hiDiffM5 > 0 then hiDiffM5 else 0;
def minusDMM5 =  if loDiffM5 > hiDiffM5 and loDiffM5 > 0 then loDiffM5 else 0;

def ATRM5 = MovingAverage(averageType, TrueRange(high(period = aM5), close(period = aM5), low(period = aM5)), length);
def "DI+M5" = 100 * MovingAverage(averageType, plusDMM5, length) / ATRM5;
def "DI-M5" = 100 * MovingAverage(averageType, minusDMM5, length) / ATRM5;

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

def bullishM5 = ("DI+M5" > "DI-M5") and (ADXM5 > adxlength);
def bearishM5 = ("DI+M5" < "DI-M5") and (ADXM5 > adxlength);
def sidewaysM5 = (ADXM5 < adxlength);

def sStateM5 = if bullishM5 then 100 else if bearishM5 then -100 else 0;
def sPOSM5 = if IsNan(sStateM5) then 0 else bullishM5;
def sNEGM5 = if IsNan(sStateM5) then 0 else bearishM5;
def sSIDM5 = if IsNan(sStateM5) then 0 else if sPOSM5 or sNEGM5 then 0 else sidewaysM5;

AddLabel(showlabels and show5MIN, "5MIN", if IsNan(sStateM5) then COLOR.DARK_GRAY else
if sStateM5 == 100 then GlobalColor("Bullish") else
if sStateM5 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 7 - FIFTEEN MINUTES

def aM15 = aggregationPeriod.FIFTEEN_MIN;
def hiDiffM15 = high(period = aM15) - high(period = aM15)[1];
def loDiffM15 = low(period = aM15)[1] - low(period = aM15);

def plusDMM15 = if hiDiffM15 > loDiffM15 and hiDiffM15 > 0 then hiDiffM15 else 0;
def minusDMM15 =  if loDiffM15 > hiDiffM15 and loDiffM15 > 0 then loDiffM15 else 0;

def ATRM15 = MovingAverage(averageType, TrueRange(high(period = aM15), close(period = aM15), low(period = aM15)), length);
def "DI+M15" = 100 * MovingAverage(averageType, plusDMM15, length) / ATRM15;
def "DI-M15" = 100 * MovingAverage(averageType, minusDMM15, length) / ATRM15;

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

def bullishM15 = ("DI+M15" > "DI-M15") and (ADXM15 > adxlength);
def bearishM15 = ("DI+M15" < "DI-M15") and (ADXM15 > adxlength);
def sidewaysM15 = (ADXM15 < adxlength);

def sStateM15 = if bullishM15 then 100 else if bearishM15 then -100 else 0;
def sPOSM15 = if IsNan(sStateM15) then 0 else bullishM15;
def sNEGM15 = if IsNan(sStateM15) then 0 else bearishM15;
def sSIDM15 = if IsNan(sStateM15) then 0 else if sPOSM15 or sNEGM15 then 0 else sidewaysM15;

AddLabel(showlabels and show15MIN, "15MIN", if IsNan(sStateM15) then COLOR.DARK_GRAY else
if sStateM15 == 100 then GlobalColor("Bullish") else
if sStateM15 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 10 - HOUR

def aH1 = aggregationPeriod.HOUR;
def hiDiffH1 = high(period = aH1) - high(period = aH1)[1];
def loDiffH1 = low(period = aH1)[1] - low(period = aH1);

def plusDMH1 = if hiDiffH1 > loDiffH1 and hiDiffH1 > 0 then hiDiffH1 else 0;
def minusDMH1 =  if loDiffH1 > hiDiffH1 and loDiffH1 > 0 then loDiffH1 else 0;

def ATRH1 = MovingAverage(averageType, TrueRange(high(period = aH1), close(period = aH1), low(period = aH1)), length);
def "DI+H1" = 100 * MovingAverage(averageType, plusDMH1, length) / ATRH1;
def "DI-H1" = 100 * MovingAverage(averageType, minusDMH1, length) / ATRH1;

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

def bullishH1 = ("DI+H1" > "DI-H1") and (ADXH1 > adxlength);
def bearishH1 = ("DI+H1" < "DI-H1") and (ADXH1 > adxlength);
def sidewaysH1 = (ADXH1 < adxlength);

def sStateH1 = if bullishH1 then 100 else if bearishH1 then -100 else 0;
def sPOSH1 = if IsNan(sStateH1) then 0 else bullishH1;
def sNEGH1 = if IsNan(sStateH1) then 0 else bearishH1;
def sSIDH1 = if IsNan(sStateH1) then 0 else if sPOSH1 or sNEGH1 then 0 else sidewaysH1;

AddLabel(showlabels and show1HOUR, "1HOUR", if IsNan(sStateH1) then COLOR.DARK_GRAY else
if sStateH1 == 100 then GlobalColor("Bullish") else
if sStateH1 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 12 - FOUR HOURS

def aH4 = aggregationPeriod.FOUR_HOURS;
def hiDiffH4 = high(period = aH4) - high(period = aH4)[1];
def loDiffH4 = low(period = aH4)[1] - low(period = aH4);

def plusDMH4 = if hiDiffH4 > loDiffH4 and hiDiffH4 > 0 then hiDiffH4 else 0;
def minusDMH4 =  if loDiffH4 > hiDiffH4 and loDiffH4 > 0 then loDiffH4 else 0;

def ATRH4 = MovingAverage(averageType, TrueRange(high(period = aH4), close(period = aH4), low(period = aH4)), length);
def "DI+H4" = 100 * MovingAverage(averageType, plusDMH4, length) / ATRH4;
def "DI-H4" = 100 * MovingAverage(averageType, minusDMH4, length) / ATRH4;

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

def bullishH4 = ("DI+H4" > "DI-H4") and (ADXH4 > adxlength);
def bearishH4 = ("DI+H4" < "DI-H4") and (ADXH4 > adxlength);
def sidewaysH4 = (ADXH4 < adxlength);

def sStateH4 = if bullishH4 then 100 else if bearishH4 then -100 else 0;
def sPOSH4 = if IsNan(sStateH4) then 0 else bullishH4;
def sNEGH4 = if IsNan(sStateH4) then 0 else bearishH4;
def sSIDH4 = if IsNan(sStateH4) then 0 else if sPOSH4 or sNEGH4 then 0 else sidewaysH4;

AddLabel(showlabels and show4HOUR, "4HOUR", if IsNan(sStateH4) then COLOR.DARK_GRAY else
if sStateH4 == 100 then GlobalColor("Bullish") else
if sStateH4 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 13 - ONE DAY

def aD1 = aggregationPeriod.DAY;
def hiDiffD1 = high(period = aD1) - high(period = aD1)[1];
def loDiffD1 = low(period = aD1)[1] - low(period = aD1);

def plusDMD1 = if hiDiffD1 > loDiffD1 and hiDiffD1 > 0 then hiDiffD1 else 0;
def minusDMD1 =  if loDiffD1 > hiDiffD1 and loDiffD1 > 0 then loDiffD1 else 0;

def ATRD1 = MovingAverage(averageType, TrueRange(high(period = aD1), close(period = aD1), low(period = aD1)), length);
def "DI+D1" = 100 * MovingAverage(averageType, plusDMD1, length) / ATRD1;
def "DI-D1" = 100 * MovingAverage(averageType, minusDMD1, length) / ATRD1;

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

def bullishD1 = ("DI+D1" > "DI-D1") and (ADXD1 > adxlength);
def bearishD1 = ("DI+D1" < "DI-D1") and (ADXD1 > adxlength);
def sidewaysD1 = (ADXD1 < adxlength);

def sStateD1 = if bullishD1 then 100 else if bearishD1 then -100 else 0;
def sPOSD1 = if IsNan(sStateD1) then 0 else bullishD1;
def sNEGD1 = if IsNan(sStateD1) then 0 else bearishD1;
def sSIDD1 = if IsNan(sStateD1) then 0 else if sPOSD1 or sNEGD1 then 0 else sidewaysD1;

AddLabel(showlabels and show1DAY, "1DAY", if IsNan(sStateD1) then COLOR.DARK_GRAY else
if sStateD1 == 100 then GlobalColor("Bullish") else
if sStateD1 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 15 - THREE DAYS

def aD3 = aggregationPeriod.THREE_DAYS;
def hiDiffD3 = high(period = aD3) - high(period = aD3)[1];
def loDiffD3 = low(period = aD3)[1] - low(period = aD3);

def plusDMD3 = if hiDiffD3 > loDiffD3 and hiDiffD3 > 0 then hiDiffD3 else 0;
def minusDMD3 =  if loDiffD3 > hiDiffD3 and loDiffD3 > 0 then loDiffD3 else 0;

def ATRD3 = MovingAverage(averageType, TrueRange(high(period = aD3), close(period = aD3), low(period = aD3)), length);
def "DI+D3" = 100 * MovingAverage(averageType, plusDMD3, length) / ATRD3;
def "DI-D3" = 100 * MovingAverage(averageType, minusDMD3, length) / ATRD3;

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

def bullishD3 = ("DI+D3" > "DI-D3") and (ADXD3 > adxlength);
def bearishD3 = ("DI+D3" < "DI-D3") and (ADXD3 > adxlength);
def sidewaysD3 = (ADXD3 < adxlength);

def sStateD3 = if bullishD3 then 100 else if bearishD3 then -100 else 0;
def sPOSD3 = if IsNan(sStateD3) then 0 else bullishD3;
def sNEGD3 = if IsNan(sStateD3) then 0 else bearishD3;
def sSIDD3 = if IsNan(sStateD3) then 0 else if sPOSD3 or sNEGD3 then 0 else sidewaysD3;

AddLabel(showlabels and show3DAY, "3DAY", if IsNan(sStateD3) then COLOR.DARK_GRAY else
if sStateD3 == 100 then GlobalColor("Bullish") else
if sStateD3 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 17 - ONE WEEK

def aW1 = aggregationPeriod.WEEK;
def hiDiffW1 = high(period = aW1) - high(period = aW1)[1];
def loDiffW1 = low(period = aW1)[1] - low(period = aW1);

def plusDMW1 = if hiDiffW1 > loDiffW1 and hiDiffW1 > 0 then hiDiffW1 else 0;
def minusDMW1 =  if loDiffW1 > hiDiffW1 and loDiffW1 > 0 then loDiffW1 else 0;

def ATRW1 = MovingAverage(averageType, TrueRange(high(period = aW1), close(period = aW1), low(period = aW1)), length);
def "DI+W1" = 100 * MovingAverage(averageType, plusDMW1, length) / ATRW1;
def "DI-W1" = 100 * MovingAverage(averageType, minusDMW1, length) / ATRW1;

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

def bullishW1 = ("DI+W1" > "DI-W1") and (ADXW1 > adxlength);
def bearishW1 = ("DI+W1" < "DI-W1") and (ADXW1 > adxlength);
def sidewaysW1 = (ADXW1 < adxlength);

def sStateW1 = if bullishW1 then 100 else if bearishW1 then -100 else 0;
def sPOSW1 = if IsNan(sStateW1) then 0 else bullishW1;
def sNEGW1 = if IsNan(sStateW1) then 0 else bearishW1;
def sSIDW1 = if IsNan(sStateW1) then 0 else if sPOSW1 or sNEGW1 then 0 else sidewaysW1;

AddLabel(showlabels and showWEEK, "WEEK", if IsNan(sStateW1) then COLOR.DARK_GRAY else
if sStateW1 == 100 then GlobalColor("Bullish") else
if sStateW1 == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));


# AGGREGATION 18 - ONE MONTH

def aMM = aggregationPeriod.MONTH;
def hiDiffMM = high(period = aMM) - high(period = aMM)[1];
def loDiffMM = low(period = aMM)[1] - low(period = aMM);

def plusDMMM = if hiDiffMM > loDiffMM and hiDiffMM > 0 then hiDiffMM else 0;
def minusDMMM =  if loDiffMM > hiDiffMM and loDiffMM > 0 then loDiffMM else 0;

def ATRMM = MovingAverage(averageType, TrueRange(high(period = aMM), close(period = aMM), low(period = aMM)), length);
def "DI+MM" = 100 * MovingAverage(averageType, plusDMMM, length) / ATRMM;
def "DI-MM" = 100 * MovingAverage(averageType, minusDMMM, length) / ATRMM;

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

def bullishMM = ("DI+MM" > "DI-MM") and (ADXMM > adxlength);
def bearishMM = ("DI+MM" < "DI-MM") and (ADXMM > adxlength);
def sidewaysMM = (ADXMM < adxlength);

def sStateMM = if bullishMM then 100 else if bearishMM then -100 else 0;
def sPOSMM = if IsNan(sStateMM) then 0 else bullishMM;
def sNEGMM = if IsNan(sStateMM) then 0 else bearishMM;
def sSIDMM = if IsNan(sStateMM) then 0 else if sPOSMM or sNEGMM then 0 else sidewaysMM;

AddLabel(showlabels and showMONTH, "MONTH", if IsNan(sStateMM) then COLOR.DARK_GRAY else
if sStateMM == 100 then GlobalColor("Bullish") else
if sStateMM == -100 then GlobalColor("Bearish")
else GlobalColor("Neutral"));

#STATS
def sPOS = sPOSM1 +  sPOSM3 + sPOSM5 + sPOSM15 + sPOSH1 + sPOSH4 + sPOSD1 + sPOSD3 + sPOSW1 + sPOSMM;

def sNEG = sNEGM1 + sNEGM3 + sNEGM5 + sNEGM15 + sNEGH1 + sNEGH4 + sNEGD1 + sNEGD3 + sNEGW1 + sNEGMM;

def sSID = sSIDM1 + sSIDM3 + sSIDM5 + sSIDM15 + sSIDH1 + sSIDH4 + sSIDD1 + sSIDD3 + sSIDW1 + sSIDMM;

def sTOL = sPOS + sNEG + sSID;

AddLabel (showstats, "Bullish: " + sPOS + " (" +
  AsPercent(Round(sPOS / sTOL, 2)) + ")", GlobalColor("Bullish"));

AddLabel (showstats, "Bearish: " + sNEG + " (" +
  AsPercent(Round(sNEG / sTOL, 2)) + ")", GlobalColor("Bearish"));

AddLabel (showstats, "Neutral: " + sSID + " (" +
  AsPercent(Round(sSID / sTOL, 2)) + ")", GlobalColor("Neutral"));


# END OF Visual DMI (The 10x Bars) MTF Labels for ThinkorSwim
 
@rad14733 Thank you so much for you assistance. It definitely does work. It seems like the only difference is I have to be on the 1 minute chart for the code to work. If I am on the 5 minute chart it wont show up at all. Thank you again for the help!
 
Thank you so much for you assistance. It definitely does work. It seems like the only difference is I have to be on the 1 minute chart for the code to work. If I am on the 5 minute chart it wont show up at all. Thank you again for the help!
Your timeframe has to be set to the lowest timeframe being calculated... The best workaround is to remove the 1m section... I rarely go lower than 3m on my charts and if I do I remove most studies and indicators...
 
Your timeframe has to be set to the lowest timeframe being calculated... The best workaround is to remove the 1m section... I rarely go lower than 3m on my charts and if I do I remove most studies and indicators...
Great I will try that! Thank you again.
 
This should work for an MTF version of DMI + ADXR.
In order to get ADX and ADXR you have to calculate DMI manually and use AggPeriod to specify which timeframe you want.

Feel free to use as you wish:

Code:
declare lower;


# --- @cos251 - AggPeriod Version of DMI + ADXR

# GLOBAL VARIABLES
input length = 14;
input averageType = AverageType.WILDERS;
input aggPeriod = AggregationPeriod.TWO_MIN;

###### BEGIN ADX Symbol 1
def hiDiffsymbol1 = high(period = aggPeriod) - high(period = aggPeriod)[1];
def loDiffsymbol1 = low(period = aggPeriod)[1] - low(period = aggPeriod);
def plusDMsymbol1 = if hiDiffsymbol1 > loDiffsymbol1 and hiDiffsymbol1 > 0 then hiDiffsymbol1 else 0;
def minusDMsymbol1 =  if loDiffsymbol1 > hiDiffsymbol1 and loDiffsymbol1 > 0 then loDiffsymbol1 else 0;
def ATRsymbol1 = MovingAverage(averageType, TrueRange(high( period = aggPeriod), close(period = aggPeriod), low( period = aggPeriod)), length);
plot "DIPlussymbol1" = 100 * MovingAverage(averageType, plusDMsymbol1, length) / ATRsymbol1;
plot "DIMinussymbol1" = 100 * MovingAverage(averageType, minusDMsymbol1, length) / ATRsymbol1;
def DXsymbol1 = if ("DIPlussymbol1" + "DIMinussymbol1" > 0) then 100 * AbsValue("DIPlussymbol1" - "DIMinussymbol1") / ("DIPlussymbol1" + "DIMinussymbol1") else 0;
plot ADXsymbol1 = MovingAverage(averageType, DXsymbol1, length);
plot ADXRsymbol1 = (ADXsymbol1 + ADXsymbol1[length - 1]) / 2;
############## END ADX Symbol 1
 
This should work for an MTF version of DMI + ADXR.
In order to get ADX and ADXR you have to calculate DMI manually and use AggPeriod to specify which timeframe you want.

Feel free to use as you wish:

Code:
declare lower;


# --- @cos251 - AggPeriod Version of DMI + ADXR

# GLOBAL VARIABLES
input length = 14;
input averageType = AverageType.WILDERS;
input aggPeriod = AggregationPeriod.TWO_MIN;

###### BEGIN ADX Symbol 1
def hiDiffsymbol1 = high(period = aggPeriod) - high(period = aggPeriod)[1];
def loDiffsymbol1 = low(period = aggPeriod)[1] - low(period = aggPeriod);
def plusDMsymbol1 = if hiDiffsymbol1 > loDiffsymbol1 and hiDiffsymbol1 > 0 then hiDiffsymbol1 else 0;
def minusDMsymbol1 =  if loDiffsymbol1 > hiDiffsymbol1 and loDiffsymbol1 > 0 then loDiffsymbol1 else 0;
def ATRsymbol1 = MovingAverage(averageType, TrueRange(high( period = aggPeriod), close(period = aggPeriod), low( period = aggPeriod)), length);
plot "DIPlussymbol1" = 100 * MovingAverage(averageType, plusDMsymbol1, length) / ATRsymbol1;
plot "DIMinussymbol1" = 100 * MovingAverage(averageType, minusDMsymbol1, length) / ATRsymbol1;
def DXsymbol1 = if ("DIPlussymbol1" + "DIMinussymbol1" > 0) then 100 * AbsValue("DIPlussymbol1" - "DIMinussymbol1") / ("DIPlussymbol1" + "DIMinussymbol1") else 0;
plot ADXsymbol1 = MovingAverage(averageType, DXsymbol1, length);
plot ADXRsymbol1 = (ADXsymbol1 + ADXsymbol1[length - 1]) / 2;
############## END ADX Symbol 1
Hot Dog! That is really interesting! I dropped the plot for the "DIMinussymbol1" and the "ADXsymbol1" and noticed a discernible pattern on a 5 minute chart using a 10 min aggperiod.

Oh..I forgot...I popped a "Label" on this puppy and got an "expected double."

Here is the code again below with the "Label." You will see the syntax at the bottom. I thought that I may have missed a parenthetical mark...but, that doesn't seem to be the case. Any suggestions?

Code:
# --- [USER=6343]@cos251[/USER] - AggPeriod Version of DMI + ADXR

# GLOBAL VARIABLES

declare lower;


input length = 14;
input averageType = AverageType.WILDERS;
input aggPeriod = AggregationPeriod.TWO_MIN;

###### BEGIN ADX Symbol 1
def hiDiffsymbol1 = high(period = aggPeriod) - high(period = aggPeriod)[1];
def loDiffsymbol1 = low(period = aggPeriod)[1] - low(period = aggPeriod);
def plusDMsymbol1 = if hiDiffsymbol1 > loDiffsymbol1 and hiDiffsymbol1 > 0 then hiDiffsymbol1 else 0;
def minusDMsymbol1 =  if loDiffsymbol1 > hiDiffsymbol1 and loDiffsymbol1 > 0 then loDiffsymbol1 else 0;
def ATRsymbol1 = MovingAverage(averageType, TrueRange(high( period = aggPeriod), close(period = aggPeriod), low( period = aggPeriod)), length);
plot "DIPlussymbol1" = 100 * MovingAverage(averageType, plusDMsymbol1, length) / ATRsymbol1;
plot "DIMinussymbol1" = 100 * MovingAverage(averageType, minusDMsymbol1, length) / ATRsymbol1;
def DXsymbol1 = if ("DIPlussymbol1" + "DIMinussymbol1" > 0) then 100 * AbsValue("DIPlussymbol1" - "DIMinussymbol1") / ("DIPlussymbol1" + "DIMinussymbol1") else 0;
plot ADXsymbol1 = MovingAverage(averageType, DXsymbol1, length);
plot ADXRsymbol1 = (ADXsymbol1 + ADXsymbol1[length - 1]) / 2;

AddLabel (yes, "ADXPlus", if DIPlussymbol1 > ADXRsymbol1 then Color.RED else Color.GREEN);
############## END ADX Symbol 1

Thanks!
 
Last edited:

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
205 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