Repaints The Multi-10x MTF Labels Indicator for ThinkorSwim

Repaints
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?

# --- @cos251 - 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!
This may work.

Code:
AddLabel (yes, "ADX: "+ADXsymbol1, if "DIPlussymbol1" > ADXRsymbol1 then Color.RED else Color.GREEN);
 

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

Hi all-

I have the 10X bars on my TOS charts but am trying to get the light blue dots on the bars. The dots should appear when volume is 50% over the 20 bar average volume. This is what JC considers CONVICTION. Does anyone have a script for this? I'm spinning my wheels as I am not very good with thinkscript. I have a screenshot to double check the script.

As always, thanks. It takes a village......

Cindy
 
@cbfenner Not sure what 10x bar is but this will plot dots if volume is greater than 1.5.
Code:
plot dots = if volume > 1.5 * Average(volume, 20) then close else Double.NaN;
dots.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
 
@cbfenner Not sure what 10x bar is but this will plot dots if volume is greater than 1.5.
Code:
plot dots = if volume > 1.5 * Average(volume, 20) then close else Double.NaN;
dots.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
THANKS! I think that works. Will double check in the morning after my coffee. : ) 10X bars are something that John Carter uses at Simpler Trading. The candles change colors from red to yellow to green to show changes in momentum. Then these dots will help show "conviction" as there is higher volume in addition to momentum.
 
Hi all-

I have the 10X bars on my TOS charts but am trying to get the light blue dots on the bars. The dots should appear when volume is 50% over the 20 bar average volume. This is what JC considers CONVICTION. Does anyone have a script for this? I'm spinning my wheels as I am not very good with thinkscript. I have a screenshot to double check the script.

As always, thanks. It takes a village......

Cindy
if you dont mind , can you please share the script for 10x bars?
 
I think someone already posted the complete 10x bars in this site somewhere. I only wanted the volume dot from it so I stole that part. This is what I use.

Ruby:
input volumeOscThreshold = 0.7;
def volumeOsc = reference VolumeOsc("fast length" = 1, "slow length" = 20, "diff type" = "percent");
plot VolumeSpike = volumeOsc > volumeOscThreshold;
VolumeSpike.SetDefaultColor(Color.CYAN);
VolumeSpike.SetLineWeight(3);
VolumeSpike.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
VolumeSpike.HideBubble();
VolumeSpike.HideTitle();
 
@sierioiza After a quick code review I see several issues with your study set.

Firstly it seems that you are attempting to build some sort of an MTF indicator using the script() function.
Assuming you want to use this feature to process secondary aggregations, take note that using the script() function to handle secondary aggregations do not work. You might like to read my post at

https://usethinkscript.com/threads/...dies-utilizing-script-for-secondary-aggs.969/
Then you might like to consider a restructure of your code logic in light of that

Second issue is with the variable "dStr". The data is static. You probably want to dynamically determine the chart aggregation and then run a comparison with your AddLabel() statement. Suggest you use GetAggregationPeriod() to achieve that. The rest of your AddLabel statement seems to be fine. Great job on that by the way.

Here then is the modified section, once you have loaded that into a chart study then set your chart to different aggregations and see it do its thing.

Code:
def dStr = GetAggregationPeriod();
AddLabel(yes, if dStr == aggregationPeriod.MONTH then "M"
              else if dStr == aggregationPeriod.WEEK then "W"
              else if dStr == aggregationPeriod.FOUR_DAYS then "4D"
              else if dStr == aggregationPeriod.THREE_DAYS then "3D"
              else if dStr == aggregationPeriod.TWO_DAYS then "2D"
              else if dStr == aggregationPeriod.DAY then "D"
              else if dStr == aggregationPeriod.FOUR_HOURS then "4H"
              else if dStr == aggregationPeriod.TWO_HOURS then "2H"
              else if dStr == aggregationPeriod.HOUR then "1H"
              else if dStr == aggregationPeriod.THIRTY_MIN then "30m"
              else if dStr == aggregationPeriod.TWENTY_MIN then "20m"
              else if dStr == aggregationPeriod.FIFTEEN_MIN then "15m"
              else if dStr == aggregationPeriod.TEN_MIN then "10m"
              else if dStr == aggregationPeriod.FIVE_MIN then "5m"
              else if dStr == aggregationPeriod.FOUR_MIN then "4m"
              else if dStr == aggregationPeriod.THREE_MIN then "3m"
              else if dStr == aggregationPeriod.TWO_MIN then "2m"
              else if dStr == aggregationPeriod.MIN then "1m"
              else "", Color.GREEN);

hal_agg hal_agglabel

i was just scrolling through the posts and came across this long formula in an addlabel, in post #2. i skimmed through the 8 pages and didn't see a simpler version of this, so i threw this together. i think this post may have evolved into something else, but i thought my version might come in handy for someone's project. reduced code lines, from 18 to 6.

Ruby:
def agg2 = GetAggregationPeriod();
def agg2min =  agg2/60000;

AddLabel(1, "alt " + if agg2min < 60 then (agg2min + "m")
              else if agg2min < 1440 then ((agg2min/60) + "H")
              else if agg2min < 10080 then (agg2min/(60*24) + "D")
              else if agg2 == aggregationPeriod.WEEK then "W"
              else if agg2 == aggregationPeriod.MONTH then "M"
              else "", Color.cyan);

addlabel(1, "chart min " + agg2/60000, color.cyan);

# agg
# time in min

# min    1
# min   15
# min   30
# hour  60 --
# 2h   120
# 4h   240  /60
# day 1440 --
# 2d  2880
# 3d  4320
# 4d  5760  / (60*24)
# w 10,080 --
# m 43.200 --
#
 
Last edited:
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);
Thank you for this information. A quick question regarding input volume greater percent: I am assuming this is the setting that will display when the volume is 50% above its average. Would this be correct? I believe John at ST uses 30% additional volume. Please kindly advise.

Thank you.
 
I am seeking clarification on the volume greater percent input (bolded and underlined) as it relates to the 10X Bars script posted below.

Would I be correct in assuming this input will display volume that is 50% greater than the average based on the timeframe one is looking at?

Thank you again.
Ruby:
#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.Dark_ORANGE);
volDot.SetLineWeight(2);
#AssignPriceColor(Color.BLUE);
 
Last edited by a moderator:
@JamesF To find out what is actually plotting on a chart, look at the PLOT statement in the study.

In this study there is, as you highlighted
a user input statement input volumeGreaterPercent = 50 and​
a definition statement def vol50IncLevel = volAvg * (1 + (volumeGreaterPercent / 100))
a plot statement plot volDot = if volume >= vol50IncLevel

This says there is only a plot if volume is greater than or equal to AverageVolume * (1 + (volumeGreaterPercent / 100))
 
I'm looking for some help on an issue. I modified the code so that there are three different dots based on varying percentages of volume. So, I essentially added three sets of dot plots. I also made the dots plot on the candle relative to the measure of volume. This is adjustable in the menu to whatever % you want.

Now, what I would like to do is only display one of the dots, whichever is highest. The candle gets cluttered and having multiple dots is not useful. I know it's probably a simple if/then statement, but I'm not a coder so if someone could give me a clue, that would be super helpful. Oh, also, if I could figure out how to match the color of the dot to the volume bar that would be great as well.

Below is the modified code:
Ruby:
input length = 14;
input averageType = AverageType.WILDERS;
input volumeLength = 20;
input volumeFactor = 1;
input plotVolumeDotOnNeutral = no;
input volumeGreaterPercent1 = 25;
input volumeGreaterPercent2 = 50;
input volumeGreaterPercent3 = 75;

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;

#Get moving average of volume
def volAvg = MovingAverage(length = volumeLength,data = volume);
#Calculate bottom of bar
def volDotLocation1 = volumeFactor * MidBodyVal() - 0.5 * Bodyheight();
#calculate Lower % increase in average volume
def vol50IncLevel1 = volAvg * (1 + (volumeGreaterPercent1 / 100));
def volDotLocation2 = volumeFactor * MidBodyVal();
#calculate Mid % increase in average volume
def vol50IncLevel2 = volAvg * (1 + (volumeGreaterPercent2 / 100));
def volDotLocation3 = volumeFactor * MidBodyVal() + 0.5 * BodyHeight();
#calculate Upper % increase in average volume
def vol50IncLevel3 = volAvg * (1 + (volumeGreaterPercent3 / 100));
#if current volume is greater than the configured length MA of the volume then plot volume dot
plot volDot1 = if volume >= vol50IncLevel1 then volDotLocation1 else Double.NaN;
plot volDot2 = if volume >= vol50IncLevel2 then volDotLocation1 else Double.NaN;
plot volDot3 = if volume >= vol50IncLevel3 then volDotLocation1 else Double.NaN;
volDot1.SetStyle(Curve.POINTS);
volDot1.SetDefaultColor(Color.Red);
volDot1.SetLineWeight(2);
volDot2.SetStyle(Curve.POINTS);
volDot2.SetDefaultColor(Color.Yellow);
volDot2.SetLineWeight(2);
volDot3.SetStyle(Curve.POINTS);
volDot3.SetDefaultColor(Color.Blue);
volDot3.SetLineWeight(2);


Thanks in advance for the help.
 
Last edited by a moderator:
I'm looking for some help on an issue. I modified the code so that there are three different dots based on varying percentages of volume. So, I essentially added three sets of dot plots. I also made the dots plot on the candle relative to the measure of volume. This is adjustable in the menu to whatever % you want.

Now, what I would like to do is only display one of the dots, whichever is highest. The candle gets cluttered and having multiple dots is not useful. I know it's probably a simple if/then statement, but I'm not a coder so if someone could give me a clue, that would be super helpful. Oh, also, if I could figure out how to match the color of the dot to the volume bar that would be great as well.

Below is the modified code:
Ruby:
input length = 14;
input averageType = AverageType.WILDERS;
input volumeLength = 20;
input volumeFactor = 1;
input plotVolumeDotOnNeutral = no;
input volumeGreaterPercent1 = 25;
input volumeGreaterPercent2 = 50;
input volumeGreaterPercent3 = 75;

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;

#Get moving average of volume
def volAvg = MovingAverage(length = volumeLength,data = volume);
#Calculate bottom of bar
def volDotLocation1 = volumeFactor * MidBodyVal() - 0.5 * Bodyheight();
#calculate Lower % increase in average volume
def vol50IncLevel1 = volAvg * (1 + (volumeGreaterPercent1 / 100));
def volDotLocation2 = volumeFactor * MidBodyVal();
#calculate Mid % increase in average volume
def vol50IncLevel2 = volAvg * (1 + (volumeGreaterPercent2 / 100));
def volDotLocation3 = volumeFactor * MidBodyVal() + 0.5 * BodyHeight();
#calculate Upper % increase in average volume
def vol50IncLevel3 = volAvg * (1 + (volumeGreaterPercent3 / 100));
#if current volume is greater than the configured length MA of the volume then plot volume dot
plot volDot1 = if volume >= vol50IncLevel1 then volDotLocation1 else Double.NaN;
plot volDot2 = if volume >= vol50IncLevel2 then volDotLocation1 else Double.NaN;
plot volDot3 = if volume >= vol50IncLevel3 then volDotLocation1 else Double.NaN;
volDot1.SetStyle(Curve.POINTS);
volDot1.SetDefaultColor(Color.Red);
volDot1.SetLineWeight(2);
volDot2.SetStyle(Curve.POINTS);
volDot2.SetDefaultColor(Color.Yellow);
volDot2.SetLineWeight(2);
volDot3.SetStyle(Curve.POINTS);
volDot3.SetDefaultColor(Color.Blue);
volDot3.SetLineWeight(2);


Thanks in advance for the help.
If you use the Double.nan with an if then else statement and start with the highest precedent and then work your way down.
You only need to plot 1 dot , but change the color of the dot , so you would only need 1 double.Nan statement. Change the color by using assignvaluecolor statement with a multiple if then statement
 
***All the below code works great however I am not a coder and was wondering if we could remove the color candles and keep the
volume dots. ***
https://usethinkscript.com/threads/...icator-for-thinkorswim.1129/page-3#post-10627

Can anyone with coding skillz help here....

#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);
 
Last edited by a moderator:
Updated 1.2 - All 18 periods are now included.

Ruby:
#Visual DMI (The 10x Bars) MTF Labels for ThinkorSwim
#Last Updated on Monday, November 25 2019 at 09:34:43 AM
#
#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, 4DAYS
#
#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;
input averageType = AverageType.WILDERS;

# 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(yes, "10X System", 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 > 20);
def bearishM1 = ("DI+M1" < "DI-M1") and (ADXM1 > 20);
def sidewaysM1 = (ADXM1 < 20);

AddLabel(1, "1MIN", if bullishM1 then GlobalColor("Bullish") else
 if bearishM1 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 2 - TWO MINUTES

def aM2 = aggregationPeriod.TWO_MIN;
def hiDiffM2 = high(period = aM2) - high(period = aM2)[1];
def loDiffM2 = low(period = aM2)[1] - low(period = aM2);

def plusDMM2 = if hiDiffM2 > loDiffM2 and hiDiffM2 > 0 then hiDiffM2 else 0;
def minusDMM2 =  if loDiffM2 > hiDiffM2 and loDiffM2 > 0 then loDiffM2 else 0;

def ATRM2 = MovingAverage(averageType, TrueRange(high(period = aM2), close(period = aM2), low(period = aM2)), length);
def "DI+M2" = 100 * MovingAverage(averageType, plusDMM2, length) / ATRM2;
def "DI-M2" = 100 * MovingAverage(averageType, minusDMM2, length) / ATRM2;

def DXM2 = if ("DI+M2" + "DI-M2" > 0) then 100 * AbsValue("DI+M2" - "DI-M2") / ("DI+M2" + "DI-M2") else 0;
def ADXM2 = MovingAverage(averageType, DXM2, length);

def bullishM2 = ("DI+M2" > "DI-M2") and (ADXM2 > 20);
def bearishM2 = ("DI+M2" < "DI-M2") and (ADXM2 > 20);
def sidewaysM2 = (ADXM2 < 20);

AddLabel(1, "2MIN", if bullishM2 then GlobalColor("Bullish") else
 if bearishM2 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 > 20);
def bearishM3 = ("DI+M3" < "DI-M3") and (ADXM3 > 20);
def sidewaysM3 = (ADXM3 < 20);

AddLabel(1, "3MIN", if bullishM3 then GlobalColor("Bullish") else
 if bearishM3 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 4 - FOUR MINUTES

def aM4 = aggregationPeriod.FOUR_MIN;
def hiDiffM4 = high(period = aM4) - high(period = aM4)[1];
def loDiffM4 = low(period = aM4)[1] - low(period = aM4);

def plusDMM4 = if hiDiffM4 > loDiffM4 and hiDiffM4 > 0 then hiDiffM4 else 0;
def minusDMM4 =  if loDiffM4 > hiDiffM4 and loDiffM4 > 0 then loDiffM4 else 0;

def ATRM4 = MovingAverage(averageType, TrueRange(high(period = aM4), close(period = aM4), low(period = aM4)), length);
def "DI+M4" = 100 * MovingAverage(averageType, plusDMM4, length) / ATRM4;
def "DI-M4" = 100 * MovingAverage(averageType, minusDMM4, length) / ATRM4;

def DXM4 = if ("DI+M4" + "DI-M4" > 0) then 100 * AbsValue("DI+M4" - "DI-M4") / ("DI+M4" + "DI-M4") else 0;
def ADXM4 = MovingAverage(averageType, DXM4, length);

def bullishM4 = ("DI+M4" > "DI-M4") and (ADXM4 > 20);
def bearishM4 = ("DI+M4" < "DI-M4") and (ADXM4 > 20);
def sidewaysM4 = (ADXM4 < 20);

AddLabel(1, "4MIN", if bullishM4 then GlobalColor("Bullish") else
 if bearishM4 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 > 20);
def bearishM5 = ("DI+M5" < "DI-M5") and (ADXM5 > 20);
def sidewaysM5 = (ADXM5 < 20);

AddLabel(1, "5MIN", if bullishM5 then GlobalColor("Bullish") else
 if bearishM5 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 6 - TEN MINUTES

def aM10 = aggregationPeriod.TEN_MIN;
def hiDiffM10 = high(period = aM10) - high(period = aM10)[1];
def loDiffM10 = low(period = aM10)[1] - low(period = aM10);

def plusDMM10 = if hiDiffM10 > loDiffM10 and hiDiffM10 > 0 then hiDiffM10 else 0;
def minusDMM10 =  if loDiffM10 > hiDiffM10 and loDiffM10 > 0 then loDiffM10 else 0;

def ATRM10 = MovingAverage(averageType, TrueRange(high(period = aM10), close(period = aM10), low(period = aM10)), length);
def "DI+M10" = 100 * MovingAverage(averageType, plusDMM10, length) / ATRM10;
def "DI-M10" = 100 * MovingAverage(averageType, minusDMM10, length) / ATRM10;

def DXM10 = if ("DI+M10" + "DI-M10" > 0) then 100 * AbsValue("DI+M10" - "DI-M10") / ("DI+M10" + "DI-M10") else 0;
def ADXM10 = MovingAverage(averageType, DXM10, length);

def bullishM10 = ("DI+M10" > "DI-M10") and (ADXM10 > 20);
def bearishM10 = ("DI+M10" < "DI-M10") and (ADXM10 > 20);
def sidewaysM10 = (ADXM10 < 20);

AddLabel(1, "10MIN", if bullishM10 then GlobalColor("Bullish") else
 if bearishM10 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 > 20);
def bearishM15 = ("DI+M15" < "DI-M15") and (ADXM15 > 20);
def sidewaysM15 = (ADXM15 < 20);

AddLabel(1, "15MIN", if bullishM15 then GlobalColor("Bullish") else
 if bearishM15 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 8 - TWENTY MINUTES

def aM20 = aggregationPeriod.TWENTY_MIN;
def hiDiffM20 = high(period = aM20) - high(period = aM20)[1];
def loDiffM20 = low(period = aM20)[1] - low(period = aM20);

def plusDMM20 = if hiDiffM20 > loDiffM20 and hiDiffM20 > 0 then hiDiffM20 else 0;
def minusDMM20 =  if loDiffM20 > hiDiffM20 and loDiffM20 > 0 then loDiffM20 else 0;

def ATRM20 = MovingAverage(averageType, TrueRange(high(period = aM20), close(period = aM20), low(period = aM20)), length);
def "DI+M20" = 100 * MovingAverage(averageType, plusDMM20, length) / ATRM20;
def "DI-M20" = 100 * MovingAverage(averageType, minusDMM20, length) / ATRM20;

def DXM20 = if ("DI+M20" + "DI-M20" > 0) then 100 * AbsValue("DI+M20" - "DI-M20") / ("DI+M20" + "DI-M20") else 0;
def ADXM20 = MovingAverage(averageType, DXM20, length);

def bullishM20 = ("DI+M20" > "DI-M20") and (ADXM20 > 20);
def bearishM20 = ("DI+M20" < "DI-M20") and (ADXM20 > 20);
def sidewaysM20 = (ADXM20 < 20);

AddLabel(1, "20MIN", if bullishM20 then GlobalColor("Bullish") else
 if bearishM20 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 9 - THIRTY MINUTES

def aM30 = aggregationPeriod.THIRTY_MIN;
def hiDiffM30 = high(period = aM30) - high(period = aM30)[1];
def loDiffM30 = low(period = aM30)[1] - low(period = aM30);

def plusDMM30 = if hiDiffM30 > loDiffM30 and hiDiffM30 > 0 then hiDiffM30 else 0;
def minusDMM30 =  if loDiffM30 > hiDiffM30 and loDiffM30 > 0 then loDiffM30 else 0;

def ATRM30 = MovingAverage(averageType, TrueRange(high(period = aM30), close(period = aM30), low(period = aM30)), length);
def "DI+M30" = 100 * MovingAverage(averageType, plusDMM30, length) / ATRM30;
def "DI-M30" = 100 * MovingAverage(averageType, minusDMM30, length) / ATRM30;

def DXM30 = if ("DI+M30" + "DI-M30" > 0) then 100 * AbsValue("DI+M30" - "DI-M30") / ("DI+M30" + "DI-M30") else 0;
def ADXM30 = MovingAverage(averageType, DXM30, length);

def bullishM30 = ("DI+M30" > "DI-M30") and (ADXM30 > 20);
def bearishM30 = ("DI+M30" < "DI-M30") and (ADXM30 > 20);
def sidewaysM30 = (ADXM30 < 20);

AddLabel(1, "30MIN", if bullishM30 then GlobalColor("Bullish") else
 if bearishM30 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 > 20);
def bearishH1 = ("DI+H1" < "DI-H1") and (ADXH1 > 20);
def sidewaysH1 = (ADXH1 < 20);

AddLabel(1, "1HOUR", if bullishH1 then GlobalColor("Bullish") else
 if bearishH1 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 11 - TWO HOURS

def aH2 = aggregationPeriod.TWO_HOURS;
def hiDiffH2 = high(period = aH2) - high(period = aH2)[1];
def loDiffH2 = low(period = aH2)[1] - low(period = aH2);

def plusDMH2 = if hiDiffH2 > loDiffH2 and hiDiffH2 > 0 then hiDiffH2 else 0;
def minusDMH2 =  if loDiffH2 > hiDiffH2 and loDiffH2 > 0 then loDiffH2 else 0;

def ATRH2 = MovingAverage(averageType, TrueRange(high(period = aH2), close(period = aH2), low(period = aH2)), length);
def "DI+H2" = 100 * MovingAverage(averageType, plusDMH2, length) / ATRH2;
def "DI-H2" = 100 * MovingAverage(averageType, minusDMH2, length) / ATRH2;

def DXH2 = if ("DI+H2" + "DI-H2" > 0) then 100 * AbsValue("DI+H2" - "DI-H2") / ("DI+H2" + "DI-H2") else 0;
def ADXH2 = MovingAverage(averageType, DXH2, length);

def bullishH2 = ("DI+H2" > "DI-H2") and (ADXH2 > 20);
def bearishH2 = ("DI+H2" < "DI-H2") and (ADXH2 > 20);
def sidewaysH2 = (ADXH2 < 20);

AddLabel(1, "2HOUR", if bullishH2 then GlobalColor("Bullish") else
 if bearishH2 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 > 20);
def bearishH4 = ("DI+H4" < "DI-H4") and (ADXH4 > 20);
def sidewaysH4 = (ADXH4 < 20);

AddLabel(1, "4HOUR", if bullishH4 then GlobalColor("Bullish") else
 if bearishH4 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 > 20);
def bearishD1 = ("DI+D1" < "DI-D1") and (ADXD1 > 20);
def sidewaysD1 = (ADXD1 < 20);

AddLabel(1, "1DAY", if bullishD1 then GlobalColor("Bullish") else
 if bearishD1 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 14 - TWO DAYS

def aD2 = aggregationPeriod.TWO_DAYS;
def hiDiffD2 = high(period = aD2) - high(period = aD2)[1];
def loDiffD2 = low(period = aD2)[1] - low(period = aD2);

def plusDMD2 = if hiDiffD2 > loDiffD2 and hiDiffD2 > 0 then hiDiffD2 else 0;
def minusDMD2 =  if loDiffD2 > hiDiffD2 and loDiffD2 > 0 then loDiffD2 else 0;

def ATRD2 = MovingAverage(averageType, TrueRange(high(period = aD2), close(period = aD2), low(period = aD2)), length);
def "DI+D2" = 100 * MovingAverage(averageType, plusDMD2, length) / ATRD2;
def "DI-D2" = 100 * MovingAverage(averageType, minusDMD2, length) / ATRD2;

def DXD2 = if ("DI+D2" + "DI-D2" > 0) then 100 * AbsValue("DI+D2" - "DI-D2") / ("DI+D2" + "DI-D2") else 0;
def ADXD2 = MovingAverage(averageType, DXD2, length);

def bullishD2 = ("DI+D2" > "DI-D2") and (ADXD2 > 20);
def bearishD2 = ("DI+D2" < "DI-D2") and (ADXD2 > 20);
def sidewaysD2 = (ADXD2 < 20);

AddLabel(1, "2DAY", if bullishD2 then GlobalColor("Bullish") else
 if bearishD2 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 > 20);
def bearishD3 = ("DI+D3" < "DI-D3") and (ADXD3 > 20);
def sidewaysD3 = (ADXD3 < 20);

AddLabel(1, "3DAY", if bullishD3 then GlobalColor("Bullish") else
 if bearishD3 then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# AGGREGATION 16 - FOUR DAYS

def aD4 = aggregationPeriod.FOUR_DAYS;
def hiDiffD4 = high(period = aD4) - high(period = aD4)[1];
def loDiffD4 = low(period = aD4)[1] - low(period = aD4);

def plusDMD4 = if hiDiffD4 > loDiffD4 and hiDiffD4 > 0 then hiDiffD4 else 0;
def minusDMD4 =  if loDiffD4 > hiDiffD4 and loDiffD4 > 0 then loDiffD4 else 0;

def ATRD4 = MovingAverage(averageType, TrueRange(high(period = aD4), close(period = aD4), low(period = aD4)), length);
def "DI+D4" = 100 * MovingAverage(averageType, plusDMD4, length) / ATRD4;
def "DI-D4" = 100 * MovingAverage(averageType, minusDMD4, length) / ATRD4;

def DXD4 = if ("DI+D4" + "DI-D4" > 0) then 100 * AbsValue("DI+D4" - "DI-D4") / ("DI+D4" + "DI-D4") else 0;
def ADXD4 = MovingAverage(averageType, DXD4, length);

def bullishD4 = ("DI+D4" > "DI-D4") and (ADXD4 > 20);
def bearishD4 = ("DI+D4" < "DI-D4") and (ADXD4 > 20);
def sidewaysD4 = (ADXD4 < 20);

AddLabel(1, "4DAY", if bullishD4 then GlobalColor("Bullish") else
 if bearishD4 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 > 20);
def bearishW1 = ("DI+W1" < "DI-W1") and (ADXW1 > 20);
def sidewaysW1 = (ADXW1 < 20);

AddLabel(1, "WEEK", if bullishW1 then GlobalColor("Bullish") else
 if bearishW1 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 > 20);
def bearishMM = ("DI+MM" < "DI-MM") and (ADXMM > 20);
def sidewaysMM = (ADXMM < 20);

AddLabel(1, "MONTH", if bullishMM then GlobalColor("Bullish") else
 if bearishMM then GlobalColor("Bearish")
 else GlobalColor("Neutral"));


# END OF Visual DMI (The 10x Bars) MTF Labels for ThinkorSwim
this only work on 1min chart if i set for 5min no lable is loading so can you pl tell what to fix on code.
also can you add the candle color when adx is abovut 23 candle color will green.
 

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
2161 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