@skynetgen Thanks for sharing. I'm digging it.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
@skynetgen To clarify - on a 5 min chart you are setting the agg period to 15 min?So I think I found a perfect MTF compliment for this. This is based on hguru CCIATRMTF cloud (fixed a few bugs and simplified a bit)
using 15min for 5min and 4h for 30m
https://tos.mx/T8ikSO8
yep. on 30m to 4h and on daily to weekly@skynetgen To clarify - on a 5 min chart you are setting the agg period to 15 min?
For daily I am using stock HHLLS and stock study I uploaded (10/13/20). I also use same for 5m and 30m. Did not test extensively weekly/monthly - I do expect it would need some shortening of periods there@skynetgen could you share your build, so I can match your settings?
on 30m to 4h and on daily to weekly
# HHLLS
# blt
# 4.28.2016
# Here is a new TOS indicator that was in S&C Trader's Tips, but has not been made part of the native TOS studies list yet.
# It is working very well on my 1min chart with the length of 8. The only other change to the indicator that I made was to add the cloud.
declare lower;
input length = 20;
input over_bought = 60;
input signal_line = 50;
input over_sold = 10;
input averageType = AverageType.EXPONENTIAL;
Assert(length > 1, "'length' must be greater than one: " + length);
def HH = if high > high[1] then (high - Lowest(high, length)) / (Highest(high, length) - Lowest(high, length)) else 0;
def LL = if low < low[1] then (Highest(low, length) - low) / (Highest(low, length) - Lowest(low, length)) else 0;
plot HHS = 100 * MovingAverage(averageType, HH, length);
plot LLS = 100 * MovingAverage(averageType, LL, length);
plot OverBought = over_bought;
plot SignalLine = signal_line;
plot OverSold = over_sold;
HHS.SetDefaultColor(GetColor(6));
LLS.SetDefaultColor(GetColor(5));
OverBought.SetDefaultColor(GetColor(7));
SignalLine.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
addcloud(hhs,lls,color.green,color.red);
# End Study
Is there a MTF indicator for this one?Found this interesting script on TradingView. I think it's based on Jim Berg's ATR Volatility Based System.
thinkScript Code
Code:# ATR Volatility Based System Jim Berg # Assembled by BenTen at useThinkScript.com # Converted from https://www.tradingview.com/script/UxWO2H5P/ input length = 10; def EntrySignal = close > (lowest(low, 20) + 2 * atr(Length)); def ExitSignal = close < (highest(high, 20) - 2 * atr(Length)); def TrailStop = highest(close - 2 * atr(Length), 15); def ProfitTaker = expAverage(high, 13) + 2 * atr(Length); assignPriceColor(if EntrySignal then Color.GREEN else if ExitSignal then Color.RED else Color.WHITE); def entry = ((lowest(low, 20)) + 2 * atr(Length)); def exit = ((highest(high, 20)) - 2 * atr(Length)); plot trail = TrailStop; plot profit_taker = ProfitTaker; trail.SetDefaultColor(GetColor(0)); profit_taker.SetDefaultColor(GetColor(1)); AddCloud(entry, exit, color.yellow, color.yellow);
This indicator is really excellent. However, today the arrows stopped showing up on some futures and equity charts. I can still look at the crossovers for the signals but I like the arrows. They make it easier to read the chart. The arrows work on SPY and QQQ but don't work on /ES or AAPL. Any idea why?So I think I found a perfect MTF compliment for this. This is based on hguru CCIATRMTF cloud (fixed a few bugs and simplified a bit)
using 15min for 5min and 4h for 30m
https://tos.mx/T8ikSO8
# SuperTrend CCI ATR Based on hguru | Paris | BLT
input agg = AggregationPeriod.MIN;
def c = close(period = agg);
def h = high(period = agg);
def l = low(period = agg);
def pricedata = hl2(period = agg);
input show_cloud = yes;
input show_entryarrows = yes;
DefineGlobalColor("TrendUp", CreateColor(0, 102, 255));# CreateColor(0, 255, 255));
DefineGlobalColor("TrendDown",color.dark_orange);# CreateColor(0, 102, 255));
#============================= SuperTrend 2016 ===========================#
#==================== Translation for TOS by Syracusepro =================#
input Factor = 1.3; #hint Factor: supertrend ATR factor. /n influences ST and cloud
input Pd = 20; #hint PD: supertrend atr
input Lookback = 3; #hint Lookback: supertrend lookback delay
def atr_st = Average(TrueRange(h, c, l), Pd);
def Up = pricedata[Lookback] - (Factor * atr_st);
def Dn = pricedata[Lookback] + (Factor * atr_st);
def TrendUp = if c > TrendUp[1] then Max(Up, TrendUp[1]) else Up;
def TrendDown = if c < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn;
def Trend = if c > TrendDown[1] then 1 else if c < TrendUp[1] then -1 else (Trend[1]);
def Trendbn = if c > TrendDown[1] then BarNumber() else if c < TrendUp[1] then BarNumber() else (Trendbn[1]);
def Trendc = if c > TrendDown[1] then c else if c < TrendUp[1] then c else (Trendc[1]);
plot Tsl = if Trend == 1 then TrendUp else TrendDown;
Tsl.AssignValueColor(if Trend == 1 then GlobalColor("TrendUp") else GlobalColor("TrendDown"));
Tsl.SetLineWeight(1);
plot entryArrow = (if Trend == 1 and Trend[1] == -1 then First(Trendbn) else Double.NaN); #Up Entry Arrow
entryArrow.SetDefaultColor(Color.CYAN);entryArrow.setLineWeight(3);
entryArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
entryArrow.SetHiding(!show_entryarrows);
plot exitArrow = (if Trend == -1 and Trend[1] == 1 then First(Trendbn) else Double.NaN); #Down Entry Arrow
exitArrow.SetDefaultColor(Color.LIGHT_ORANGE);exitArrow.setLineWeight(3);
exitArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
exitArrow.SetHiding(!show_entryarrows);
#========================== End SuperTrend 2016 ===========================#
# CCI_ATR Trendline
# Mobius | Syracusepro
# Chat room request 01.28.2016
# 10.31.2018
# CCI is a study that measures distance from the mean. This study plots
# a trend line based on that distance using ATR as the locator for the line.
input lengthCCI = 20;
input lengthATR = 4;
input AtrFactor = 0.7;
def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
then 0
else (price - Average(price, lengthCCI)) / linDev / 0.015;
def MT1 = if isnan(close[1]) then close
else if CCI > 0
then Max(MT1[1], pricedata - ATRcci)
else Min(MT1[1], pricedata + ATRcci);
plot CCIATR = if MT1>0 then MT1 else pricedata; # fix for MT1
CCIATR.AssignValueColor(if c < MT1 then Color.RED else Color.GREEN);#TAKEN FROM SUPERTREND
# End Code CCI_ATR Trend
########################################################
# Cloud Combo Additions
# Ghost / Hguru
# 2.3.2019
# checks supertrend relative CCIATR
def ComboUpTrend = CCIATR > Tsl;
def ComboDnTrend = CCIATR < Tsl;
def crossup = ComboUpTrend == 1 and ComboUpTrend[1] <> 1;
def crossdn = ComboDnTrend == 1 and ComboDnTrend[1] <> 1;
AddCloud(if show_cloud and ComboUpTrend == 1 then CCIATR
else Double.NaN, if show_cloud and ComboUpTrend then Tsl
else Double.NaN, GlobalColor("TrendUp"), GlobalColor("TrendUp"));
AddCloud(if show_cloud and ComboDnTrend == 1 then Tsl
else Double.NaN, if show_cloud and ComboDnTrend == 1 then CCIATR
else Double.NaN, GlobalColor("TrendDown"), GlobalColor("TrendDown"));
Having Problems? Does the MTF indicator appear to be not working or partially working when you load the study onto your chart?This indicator is really excellent. However, today the arrows stopped showing up on some futures and equity charts. I can still look at the crossovers for the signals but I like the arrows. They make it easier to read the chart. The arrows work on SPY and QQQ but don't work on /ES or AAPL. Any idea why?
Here's the code:
Code:# SuperTrend CCI ATR Based on hguru | Paris | BLT input agg = AggregationPeriod.MIN; def c = close(period = agg); def h = high(period = agg); def l = low(period = agg); def pricedata = hl2(period = agg); input show_cloud = yes; input show_entryarrows = yes; DefineGlobalColor("TrendUp", CreateColor(0, 102, 255));# CreateColor(0, 255, 255)); DefineGlobalColor("TrendDown",color.dark_orange);# CreateColor(0, 102, 255)); #============================= SuperTrend 2016 ===========================# #==================== Translation for TOS by Syracusepro =================# input Factor = 1.3; #hint Factor: supertrend ATR factor. /n influences ST and cloud input Pd = 20; #hint PD: supertrend atr input Lookback = 3; #hint Lookback: supertrend lookback delay def atr_st = Average(TrueRange(h, c, l), Pd); def Up = pricedata[Lookback] - (Factor * atr_st); def Dn = pricedata[Lookback] + (Factor * atr_st); def TrendUp = if c > TrendUp[1] then Max(Up, TrendUp[1]) else Up; def TrendDown = if c < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn; def Trend = if c > TrendDown[1] then 1 else if c < TrendUp[1] then -1 else (Trend[1]); def Trendbn = if c > TrendDown[1] then BarNumber() else if c < TrendUp[1] then BarNumber() else (Trendbn[1]); def Trendc = if c > TrendDown[1] then c else if c < TrendUp[1] then c else (Trendc[1]); plot Tsl = if Trend == 1 then TrendUp else TrendDown; Tsl.AssignValueColor(if Trend == 1 then GlobalColor("TrendUp") else GlobalColor("TrendDown")); Tsl.SetLineWeight(1); plot entryArrow = (if Trend == 1 and Trend[1] == -1 then First(Trendbn) else Double.NaN); #Up Entry Arrow entryArrow.SetDefaultColor(Color.CYAN);entryArrow.setLineWeight(3); entryArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); entryArrow.SetHiding(!show_entryarrows); plot exitArrow = (if Trend == -1 and Trend[1] == 1 then First(Trendbn) else Double.NaN); #Down Entry Arrow exitArrow.SetDefaultColor(Color.LIGHT_ORANGE);exitArrow.setLineWeight(3); exitArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); exitArrow.SetHiding(!show_entryarrows); #========================== End SuperTrend 2016 ===========================# # CCI_ATR Trendline # Mobius | Syracusepro # Chat room request 01.28.2016 # 10.31.2018 # CCI is a study that measures distance from the mean. This study plots # a trend line based on that distance using ATR as the locator for the line. input lengthCCI = 20; input lengthATR = 4; input AtrFactor = 0.7; def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor; def price = c + l + h; def linDev = LinDev(price, lengthCCI); def CCI = if linDev == 0 then 0 else (price - Average(price, lengthCCI)) / linDev / 0.015; def MT1 = if isnan(close[1]) then close else if CCI > 0 then Max(MT1[1], pricedata - ATRcci) else Min(MT1[1], pricedata + ATRcci); plot CCIATR = if MT1>0 then MT1 else pricedata; # fix for MT1 CCIATR.AssignValueColor(if c < MT1 then Color.RED else Color.GREEN);#TAKEN FROM SUPERTREND # End Code CCI_ATR Trend ######################################################## # Cloud Combo Additions # Ghost / Hguru # 2.3.2019 # checks supertrend relative CCIATR def ComboUpTrend = CCIATR > Tsl; def ComboDnTrend = CCIATR < Tsl; def crossup = ComboUpTrend == 1 and ComboUpTrend[1] <> 1; def crossdn = ComboDnTrend == 1 and ComboDnTrend[1] <> 1; AddCloud(if show_cloud and ComboUpTrend == 1 then CCIATR else Double.NaN, if show_cloud and ComboUpTrend then Tsl else Double.NaN, GlobalColor("TrendUp"), GlobalColor("TrendUp")); AddCloud(if show_cloud and ComboDnTrend == 1 then Tsl else Double.NaN, if show_cloud and ComboDnTrend == 1 then CCIATR else Double.NaN, GlobalColor("TrendDown"), GlobalColor("TrendDown"));
Unfortunately your default MTF setting is set to the lowest time frame of 1 min. If you view a higher time frame it will not work. Simply change the code to get the current time frame and make it non MTF or change the default MTF time frame something like 15m / or change in the indicator options to 15 and set as default then you can view 5min and it will work fine on 1 min even.This indicator is really excellent. However, today the arrows stopped showing up on some futures and equity charts. I can still look at the crossovers for the signals but I like the arrows. They make it easier to read the chart. The arrows work on SPY and QQQ but don't work on /ES or AAPL. Any idea why?
Start a new thread and receive assistance from our community.
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.
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.