# Follow Line Indicator
# Coverted to ToS from TV by bigboss. Original © Dreadblitz
input BbPeriod = 21;
input BbDeviations = 1;
input UseAtrFilter = yes;
input AtrPeriod = 5;
input HideArrows = no;
def BBUpper=SimpleMovingAvg(close,BBperiod)+stdev(close, BBperiod)*BBdeviations;
def BBLower=SimpleMovingAvg(close,BBperiod)-stdev(close, BBperiod)*BBdeviations;
def BBSignal = if close>BBUpper then 1 else if close<BBLower then -1 else 0;
def TrendLine =
if BBSignal == 1 and UseATRfilter == 1 then
max(low-atr(ATRperiod),TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 1 then
min(high+atr(ATRperiod),TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 1 then
TrendLine[1]
else if BBSignal == 1 and UseATRfilter == 0 then
max(low,TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 0 then
min(high,TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 0 then
TrendLine[1]
else TrendLine[1];
def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1];
plot buy = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN;
buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy.SetDefaultColor(Color.GREEN);
buy.SetLineWeight(3);
plot sell = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN;
sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell.SetDefaultColor(Color.RED);
sell.SetLineWeight(3);
plot tline = TrendLine;
tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82));
tline.SetLineWeight(2);
Wow thank you!
Strategy looks too easy you know!? Im gonna use OnDemand and see how it all works on some old gappers that ran... Im always open to anything new or a piece of one strategy with another. !
Thank you , it helped me to get into profitable trades in SPX today and avoid false signals. I will continue to test.Hi @JP782 - Here is the follow line indicator implemented in thinkscript. I'm curious to hear your thoughts on the strategy!
Code:# Follow Line Indicator # Coverted to ToS from TV by bigboss. Original © Dreadblitz input BbPeriod = 21; input BbDeviations = 1; input UseAtrFilter = yes; input AtrPeriod = 5; input HideArrows = no; def BBUpper=SimpleMovingAvg(close,BBperiod)+stdev(close, BBperiod)*BBdeviations; def BBLower=SimpleMovingAvg(close,BBperiod)-stdev(close, BBperiod)*BBdeviations; def BBSignal = if close>BBUpper then 1 else if close<BBLower then -1 else 0; def TrendLine = if BBSignal == 1 and UseATRfilter == 1 then max(low-atr(ATRperiod),TrendLine[1]) else if BBSignal == -1 and UseATRfilter == 1 then min(high+atr(ATRperiod),TrendLine[1]) else if BBSignal == 0 and UseATRfilter == 1 then TrendLine[1] else if BBSignal == 1 and UseATRfilter == 0 then max(low,TrendLine[1]) else if BBSignal == -1 and UseATRfilter == 0 then min(high,TrendLine[1]) else if BBSignal == 0 and UseATRfilter == 0 then TrendLine[1] else TrendLine[1]; def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1]; plot buy = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN; buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP); buy.SetDefaultColor(Color.GREEN); buy.SetLineWeight(3); plot sell = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN; sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); sell.SetDefaultColor(Color.RED); sell.SetLineWeight(3); plot tline = TrendLine; tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82)); tline.SetLineWeight(2);
Here is an MTF versionWow thank you!
Strategy looks too easy you know!? Im gonna use OnDemand and see how it all works on some old gappers that ran... Im always open to anything new or a piece of one strategy with another. !
# Follow Line Indicator MTF
# Coverted to ToS from TV by bigboss. Original © Dreadblitz
input period = AggregationPeriod.FIFTEEN_MIN;
input BbPeriod = 21;
input BbDeviations = 1;
input UseAtrFilter = yes;
input AtrPeriod = 5;
input HideArrows = no;
def h = high(period=period);
def l = low(period=period);
def c = close(period=period);
def ATR = MovingAverage(AverageType.WILDERS, TrueRange(h, c, l), AtrPeriod);
def BBUpper=SimpleMovingAvg(c,BBperiod)+stdev(c, BBperiod)*BBdeviations;
def BBLower=SimpleMovingAvg(c,BBperiod)-stdev(c, BBperiod)*BBdeviations;
def BBSignal = if c>BBUpper then 1 else if c<BBLower then -1 else 0;
def TrendLine =
if BBSignal == 1 and UseATRfilter == 1 then
max(l-ATR,TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 1 then
min(h+ATR,TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 1 then
TrendLine[1]
else if BBSignal == 1 and UseATRfilter == 0 then
max(l,TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 0 then
min(h,TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 0 then
TrendLine[1]
else TrendLine[1];
def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1];
plot buy = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN;
buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy.SetDefaultColor(Color.GREEN);
buy.SetLineWeight(3);
plot sell = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN;
sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell.SetDefaultColor(Color.RED);
sell.SetLineWeight(3);
plot tline = TrendLine;
tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82));
tline.SetLineWeight(2);
Whoa!! Dude your a machine, I wish I could "see" the code like so many of youHere is an MTF version
Code:# Follow Line Indicator MTF # Coverted to ToS from TV by bigboss. Original © Dreadblitz input period = AggregationPeriod.FIFTEEN_MIN; input BbPeriod = 21; input BbDeviations = 1; input UseAtrFilter = yes; input AtrPeriod = 5; input HideArrows = no; def h = high(period=period); def l = low(period=period); def c = close(period=period); def ATR = MovingAverage(AverageType.WILDERS, TrueRange(h, c, l), AtrPeriod); def BBUpper=SimpleMovingAvg(c,BBperiod)+stdev(c, BBperiod)*BBdeviations; def BBLower=SimpleMovingAvg(c,BBperiod)-stdev(c, BBperiod)*BBdeviations; def BBSignal = if c>BBUpper then 1 else if c<BBLower then -1 else 0; def TrendLine = if BBSignal == 1 and UseATRfilter == 1 then max(l-ATR,TrendLine[1]) else if BBSignal == -1 and UseATRfilter == 1 then min(h+ATR,TrendLine[1]) else if BBSignal == 0 and UseATRfilter == 1 then TrendLine[1] else if BBSignal == 1 and UseATRfilter == 0 then max(l,TrendLine[1]) else if BBSignal == -1 and UseATRfilter == 0 then min(h,TrendLine[1]) else if BBSignal == 0 and UseATRfilter == 0 then TrendLine[1] else TrendLine[1]; def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1]; plot buy = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN; buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP); buy.SetDefaultColor(Color.GREEN); buy.SetLineWeight(3); plot sell = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN; sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); sell.SetDefaultColor(Color.RED); sell.SetLineWeight(3); plot tline = TrendLine; tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82)); tline.SetLineWeight(2);
Just curious when do we MTF version compared to earlier version?. I mainly use for day trading.Whoa!! Dude your a machine, I wish I could "see" the code like so many of you
Im thinking 5m data on 1min chart will give better signals
I like to see 5min data on 1 min chart,Just curious when do we MTF version compared to earlier version?. I mainly use for day trading.
When I backtested the buy and sell signals were different on both strategy and MTF versons.So I was just trying to clarify. Please do let me know your analysis too.I like to see 5min data on 1 min chart,
Hi JP782, please share the other 2 studies too. I would like to see it working.I like to see 5min data on 1 min chart,
Did you try setting the MTF version to the timeframe your chart is set to? The non-MTF and MTF version should display identical.When I backtested the buy and sell signals were different on both strategy and MTF versons.So I was just trying to clarify. Please do let me know your analysis too.
I used same timeframe, I will test furthee and share the discrepancies.Did you try setting the MTF version to the timeframe your chart is set to? The non-MTF and MTF version should display identical.
@JP782 Would you mind posting the other two indicators mentioned? Thanks!I want to try the strategy in this video. I found script for 2 of the 3 indicators, does anyone have this "Follow Line Indicator" tradingview script converted for TOS?
Hi @Kitchasap - It's entirely possible I missed something when I coded up the MTF version. I compared 5 min FLI MTF on a 5 min chart to 5 min FLI non-MTF on a 5 minute chart and the signals were the same. If you can post an example of discrepancy I can figure out what's causing it.I used same timeframe, I will test furthee and share the discrepancies.
It worked fine for me as well. I'm 99% sure Kitchasap isn't changing the MTF aggregation period to match their current chart timeframe.Hi @Kitchasap - It's entirely possible I missed something when I coded up the MTF version. I compared 5 min FLI MTF on a 5 min chart to 5 min FLI non-MTF on a 5 minute chart and the signals were the same. If you can post an example of discrepancy I can figure out what's causing it.
@bigboss , you guys are right , I changed the configuration, it worked fine. Thanks for your inputs.It worked fine for me as well. I'm 99% sure Kitchasap isn't changing the MTF aggregation period to match their current chart timeframe.
# Follow Line Indicator
# Coverted to ToS from TV by bigboss. Original © Dreadblitz
#https://usethinkscript.com/threads/follow-line-indicator.9789/
input BbPeriod = 9;
input BbDeviations = 1;
input UseAtrFilter = yes;
input AtrPeriod = 5;
input HideArrows = no;
def BBUpper=SimpleMovingAvg(close,BBperiod)+stdev(close, BBperiod)*BBdeviations;
def BBLower=SimpleMovingAvg(close,BBperiod)-stdev(close, BBperiod)*BBdeviations;
def BBSignal = if close>BBUpper then 1 else if close<BBLower then -1 else 0;
def TrendLine =
if BBSignal == 1 and UseATRfilter == 1 then
max(low-atr(ATRperiod),TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 1 then
min(high+atr(ATRperiod),TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 1 then
TrendLine[1]
else if BBSignal == 1 and UseATRfilter == 0 then
max(low,TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 0 then
min(high,TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 0 then
TrendLine[1]
else TrendLine[1];
def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1];
plot buy_price = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN;
buy_price.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
buy_price.SetDefaultColor(Color.GREEN);
buy_price.SetLineWeight(3);
plot sell_price = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN;
sell_price.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
sell_price.SetDefaultColor(Color.white);
sell_price.SetLineWeight(3);
plot buy_arrow = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN;
buy_arrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy_arrow.SetDefaultColor(Color.GREEN);
buy_arrow.SetLineWeight(3);
plot sell_arrow = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN;
sell_arrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell_arrow.SetDefaultColor(Color.RED);
sell_arrow.SetLineWeight(3);
plot tline = TrendLine;
tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82));
tline.SetPaintingStrategy(PaintingStrategy.DASHES);
tline.SetLineWeight(2);
Added color to barsHi @JP782 - Here is the follow line indicator implemented in thinkscript. I'm curious to hear your thoughts on the strategy!
Code:# Follow Line Indicator # Coverted to ToS from TV by bigboss. Original © Dreadblitz input BbPeriod = 21; input BbDeviations = 1; input UseAtrFilter = yes; input AtrPeriod = 5; input HideArrows = no; def BBUpper=SimpleMovingAvg(close,BBperiod)+stdev(close, BBperiod)*BBdeviations; def BBLower=SimpleMovingAvg(close,BBperiod)-stdev(close, BBperiod)*BBdeviations; def BBSignal = if close>BBUpper then 1 else if close<BBLower then -1 else 0; def TrendLine = if BBSignal == 1 and UseATRfilter == 1 then max(low-atr(ATRperiod),TrendLine[1]) else if BBSignal == -1 and UseATRfilter == 1 then min(high+atr(ATRperiod),TrendLine[1]) else if BBSignal == 0 and UseATRfilter == 1 then TrendLine[1] else if BBSignal == 1 and UseATRfilter == 0 then max(low,TrendLine[1]) else if BBSignal == -1 and UseATRfilter == 0 then min(high,TrendLine[1]) else if BBSignal == 0 and UseATRfilter == 0 then TrendLine[1] else TrendLine[1]; def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1]; plot buy = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN; buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP); buy.SetDefaultColor(Color.GREEN); buy.SetLineWeight(3); plot sell = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN; sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); sell.SetDefaultColor(Color.RED); sell.SetLineWeight(3); plot tline = TrendLine; tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82)); tline.SetLineWeight(2);
# Follow Line Indicator
# Coverted to ToS from TV by bigboss. Original © Dreadblitz
# Added PaintBars by NPTechs
input BbPeriod = 21;
input BbDeviations = 1;
input UseAtrFilter = yes;
input AtrPeriod = 5;
input HideArrows = no;
def BBUpper=SimpleMovingAvg(close,BBperiod)+stdev(close, BBperiod)*BBdeviations;
def BBLower=SimpleMovingAvg(close,BBperiod)-stdev(close, BBperiod)*BBdeviations;
def BBSignal = if close>BBUpper then 1 else if close<BBLower then -1 else 0;
def TrendLine =
if BBSignal == 1 and UseATRfilter == 1 then
max(low-atr(ATRperiod),TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 1 then
min(high+atr(ATRperiod),TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 1 then
TrendLine[1]
else if BBSignal == 1 and UseATRfilter == 0 then
max(low,TrendLine[1])
else if BBSignal == -1 and UseATRfilter == 0 then
min(high,TrendLine[1])
else if BBSignal == 0 and UseATRfilter == 0 then
TrendLine[1]
else TrendLine[1];
def iTrend = if TrendLine>TrendLine[1] then 1 else if TrendLine < TrendLine[1] then -1 else iTrend[1];
plot buy = if iTrend[1]==-1 and iTrend==1 and !HideArrows then TrendLine else Double.NaN;
buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
buy.SetDefaultColor(Color.GREEN);
buy.SetLineWeight(3);
plot sell = if iTrend[1]==1 and iTrend==-1 and !HideArrows then TrendLine else Double.NaN;
sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sell.SetDefaultColor(Color.RED);
sell.SetLineWeight(3);
plot tline = TrendLine;
tline.AssignValueColor(if iTrend > 0 then CreateColor(33,150,243) else CreateColor(255,82,82));
tline.SetLineWeight(2);
input PaintBars = Yes;
AssignPriceColor (if !PaintBars then Color.CURRENT else if iTrend > 0 then Color.GREEN else Color.RED);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.