Heikin_Ashi Indicator For ThinkOrSwim

@sunstar

A year ago I too was a newbie with creating scripts and trading. Numerous hours of research, reading and trial and error increased my comprehension of then TOS platform (creating scans, studies, watchlists, strategies etc.) and improving my trading plan. The goal is to use the information, make it your own and apply to your style of trading. Learning from this forum enabled me to share what I have learnt with others.

Please see below the shared fib script. I modified it from the original...added different colors to the trendline and also included the price to the left with the fib percentages. I also included the link showing the original thread and the script for support and resistance. One of my favorite strategies within my trading plan is to use the retracement between the 61.8% and 78.6% made by gappers to enter daily gapping/momentum trades (based on catalysts). I am currently working on a watchlist and scan for these setups and will share when completed.

https://tos.mx/WxiRzvT

Shared support and resistance created by Mobius
https://tos.mx/w9Zpw51
I'm never too! We have a high school project with teams and my goal is to make enough for some new spikes and glove for this years Freshman Baseball Team. I can't thank BenTen, Mobius, Rad and the rest for helping me get the hang of this. All the people here have been so wonderful and this also gives a great out during this Covid19 pandemic as I get to meet new people and learn somethings that we don't ususally learn in school. Thanks everyone! :) :) :) <3
 
@BenTen @Ilya @alexR @dominos101 @D_Tramp @Ghs @hexis777 @freedom Traders @JoeSD @AspaTrader @germanburrito @floydddd @rad14733 @barbaros @RickK @guyonabuffalo @Branch @bpVoodoo @Joseph patrick18

Thank you for your patience. Please see below the watchlist and the scan that correlates to the chart indicators. Ensure you use the same timeframe on your watchlist as your chart e.g. if you are using a 5 min time frame on the chart, use a 5 min timeframe for the watchlist.

Code:
#Bon Bon
# Multi time-frame Heikin Watchlist
#Created by BonBon 1/29/21
#Mirrors the Lower Level Multi_Time frame on the chart

input UsePeriod5 = AggregationPeriod.FIVE_MIN;
input UsePeriod15 = AggregationPeriod.FIFTEEN_MIN;
input UsePeriod30 = AggregationPeriod.thirty_MIN;
input UsePeriod60 = AggregationPeriod. HOUR;
input UsePeriod4hr = AggregationPeriod. FOUR_HOURS;
input UsePeriodday = AggregationPeriod.DAY;

input PaintBars = {default "yes", "no"};
input  Con_Cri = 3;
### Master Plot On/Off ###########

input Master_Heiken_Plot = Yes; #

## Heiken Aski Multi-Time Frame
## 2019 Paul Townsend v3

#Timeframe2 5 min

def aOpen5 = open(period = UsePeriod5);
def aClose5 = close(period = UsePeriod5);
def aHigh5 = high(period = UsePeriod5);
def aLow5 = low(period = UsePeriod5);

def haClose5 = (aOpen5 + aClose5 + aHigh5 + aLow5)/4;
def haOpen5 = (haOpen5[1] + haClose5[1])/2;

#def trend5 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;

#Timeframe2 15 mins

def aOpen15 = open(period = UsePeriod15);
def aClose15 = close(period = UsePeriod15);
def aHigh15 = high(period = UsePeriod15);
def aLow15 = low(period = UsePeriod15);

def haClose15 = (aOpen15 + aClose15 + aHigh15 + aLow15) / 4;
def haOpen15 = (haOpen15[1] + haClose15[1]) / 2;

#def trend15 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;

#Timeframe3  30 mins

def aOpen30 = open(period = UsePeriod30);
def aClose30 = close(period = UsePeriod30);
def aHigh30 = high(period = UsePeriod30);
def aLow30 = low(period = UsePeriod30);

def haClose30 = (aOpen30 + aClose30 + aHigh30 + aLow30) / 4;
def haOpen30 = (haOpen30[1] + haClose30[1]) / 2;

#def trend30 = if haClose30 >= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;

#Timeframe4  60mins

def aOpen60 = open(period = UsePeriod60);
def aClose60 = close(period = UsePeriod60);
def aHigh60 = high(period = UsePeriod60);
def aLow60 = low(period = UsePeriod60);

def haClose60 = (aOpen60 + aClose60 + aHigh60 + aLow60) / 4;
def haOpen60 = (haOpen60[1] + haClose60[1]) / 2;

#def trend60 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;

#Timeframe5 4hrs

def aOpen4hr = open(period = UsePeriod4hr);
def aClose4hr = close(period = UsePeriod4hr);
def aHigh4hr = high(period = UsePeriod4hr);
def aLow4hr = low(period = UsePeriod4hr);

def haClose4hr = (aOpen4hr + aClose4hr + aHigh4hr + aLow4hr) / 4;
def haOpen4hr = (haOpen4hr[1] + haClose4hr[1]) / 2;

#def trend4hr = if haClose4hr >= haOpen4hr then 1 else if haClose4hr < haOpen4hr then -1 else 0;

#Timeframe6 Day

def aOpenday = open(period = UsePeriodday);
def aCloseday = close(period = UsePeriodday);
def aHighday = high(period = UsePeriodday);
def aLowday = low(period = UsePeriodday);

def haCloseday = (aOpenday + aCloseday + aHighday + aLowday) / 4;
def haOpenday = (haOpenday[1] + haCloseday[1]) / 2;

#def trendday = if haCloseday >= haOpenday then 1 else if haCloseday [1] < haOpenday[1] then -1 else 0;

#Up Trend
def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
def Trend3 = if haClose30>= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
def Trend4 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
def Trend5_ = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
def Trend6 = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
def Trend3c = if haClose30 < haOpen30 then 1 else if haClose30[1] >= haOpen30[1] then -1 else 0;
def Trend4d = if haClose60 < haOpen60  then 1 else if haClose60[1] >= haOpen60[1] then -1 else 0;
def Trend5e= if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
def Trend6f = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

def HA_MTF_TopUP = (Trend1 + Trend2 + Trend3 + Trend4) >=  Con_Cri ;
def HA_MTF_TopDN = (Trend1a + Trend2b + Trend3c + Trend4d) >=  Con_Cri;
def HA_MTF_NoTrend = (Trend1a + Trend2b + Trend3c + Trend4d) <  Con_Cri;

def mftnewup = if HA_MTF_TopUP == 1 then 1 else 0;
def newmtfdown = if HA_MTF_TopDN == 1 then 1 else 0;
def notrend = if HA_MTF_NoTrend == 1 then 1 else 0;

def MTF_Above = mftnewup;
def MTF_Below = newmtfdown;
def MTF_NoTrend = notrend;

addlabel(yes,if MTF_Above then "3+" else if MTF_Below then "3+"  else if MTF_NoTrend then "NIL" else"NA", if MTF_Above then color.white else if MTF_Below then color.white else if  MTF_NoTrend then color.black else color.white);

AssignbackgroundColor(if MTF_Above then color.dark_green else if MTF_Below then color.red else if MTF_NoTrend then color.gray else color.black);
Thank you BonBon and please accept my apologies for "assuming" you were a male.
 
@homeplate2 ... A fellow educator!!! As a former teacher and principal many days spent writing grants, and brainstorming ways to fund activities for students was sometimes challenging but rewarding at the same time. (to see the look on student's faces when they received new basketball uniforms, soccer equipment etc.) My colleagues and I have also started using this as a way to help our families. Now that I am at the district level, my goal is to continue supporting our families and their communities. Indeed this forum has allowed for the work to continue, especially due to the pandemic. Some of my high schools are in dire need of resources!!!!! Keep it up @homeplate2. Feel free to reach out via private message if additional assistance is needed. There are many of us out there trying to make a difference for our schools and their communities!!!!!!!
 
Thanks to everyone for their work as I would not have gotten this far without your contribution. I have referenced members of the community as you have either commented or contributed to the HA forums/discussions.

After conducting research on indicators/studies that would aid in my entry and exits as well as keeping me in the trend longer than usual, I came upon Sylvan Vervoort and his work. ( I have previously used the TrendPainter, Supertrend etc.) After reading “Trading with the Heikin-Ashi Candlestick Oscillator" and “Trading Medium-Term Divergences” I began searching the site for script that emulates his work.

@BenTen, @zkm, @mc01439, @HighBredCloud, @JBTrades, @markos, @tomsk @horserider @YungTraderFromMontana @diazlaz @J007RMC

Key components
TEMA, Reversal bubbles and/or arrows, MTF indicator, Addchart script used to create the HA , does not repaint.

Strategy – long and/or short. Enter and/or exit based on reversals (however, I utilize other indicators and signals such as the RSI, MTF, increased volume, stocks with strong catalyst, RV above 2.0 and Fib retracement.

Scan
The scan comprises of the MTF script along with the script for liquidity, relative volume and/or stocks that are near (2-5%) to their 52wk high and short interest. I scan for stocks that are low float.

Watchlist
The watchlist is based on the buy and sell signals.

Feedback from members

I would like feedback from members regarding changing those candles that are “in the trend” but have a different color. (see chart). This would eliminate the number of signals that appear. (especially where there is only one red or green candle in the middle of the current trend. I have tried using strategies such as increasing the lookback period, using the previous candle(s) script but with no success. Please see notes within the chart.

Also, can someone please provide the information for making the Fib lines shorter. Please see notes within the chart.

It is a work in progress. I have made profitable trades and this indicator has allowed me to find setups before major breakouts etc. (this is in combination with the Buy-the Dip).

This is a chart without the regular candles. This shows the HA with the buy and sell signals and the Multi Time Frames. This is the main trading chart. The chart with the candlesticks is used for reference during trading. (I use two monitors when trading)
i7GJm5H.jpg


This is the above chart with the regular candles.
O3grdOi.jpg


This chart shows the Fib Lines and notes on the feedback needed.
ZrGyZKw.jpg


This chart shows the HA candles without the new HA_smoothing chart
3pBHtFX.jpg


This chart shows the scan criteria
DllROT7.jpg


Code
Code:
#Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update Jan 17th 2021
#Influenced by script from HoboTheClown / blt,http://www.thinkscripter.com, TD Hacolt etc.
#MTF based on HannTech's MTF_MACD script
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price

### YOU MUST HAVE THE STYLE SETTING FIT STUDIES ENABLED ###
#hint: The style setting Fit Studies must be enabled to use these bars.


input period = 50;
input hideCandles = yes;
input candleSmoothing = {default Valcu, Vervoort};
input show_bubble_labels = yes;
input bubbles = yes;
input arrows = yes;


#input smoothingLength = 3;

input movingAverageType = {default  TEMA, Exponential, Hull };

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Exponential:
    openMA = CompoundValue(1, ExpAverage(open, period), open);
    closeMA = CompoundValue(1, ExpAverage(close, period), close);
    highMA = CompoundValue(1, ExpAverage(high, period), high);
    lowMA = CompoundValue(1, ExpAverage(low, period), low);

case Hull:
    openMA = CompoundValue(1, HullMovingAvg(open, period), open);
    closeMA = CompoundValue(1,  HullMovingAvg(close, period), close);
    highMA = CompoundValue(1,  HullMovingAvg(high, period), high);
    lowMA = CompoundValue(1,  HullMovingAvg(low, period), low);

case TEMA:
    openMA = CompoundValue(1, TEMA(open, period), open);
    closeMA = CompoundValue(1, TEMA(close, period), close);
    highMA = CompoundValue(1, TEMA(high, period), high);
    lowMA = CompoundValue(1, TEMA(low, period), low);

}


HidePricePlot(hideCandles);

def haOpen;
def haClose;

switch (candleSmoothing){
case Valcu:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);
case Vervoort:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0 ) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);

}

plot o = haOpen;
o.Hide();

def haLow =  Min(lowMA, haOpen);
def haHigh = Max(highMA, haOpen);

#Zero Lag System - MetaStock Crossover Formula
#zero-lagging principle
#Zero-lagging TEMA average on closing prices

#Medium-term price reversals - upward trend

def avg = 34;
def TMA1 = reference TEMA(haClose, avg); # triple exponential moving average (TEMA) of 34 bars
def TMA2 =  reference TEMA(TMA1, avg);
def Diff = TMA1 - TMA2;
def ZlHa = TMA1 + Diff; #Zero-lagging TEMA average on closing prices - medium term uptrend;

#Medium-term price reversals - downward trend
def TMA1_ = reference TEMA((high + low) / 2, avg);
def Diff2 = TMA1_ - TMA2;
def ZlCl = TMA1_ + Diff2; #Zero-lagging TEMA average on closing prices - medium term doenwardtrend;

def ZlDif = ZlCl - ZlHa; # Zero-Lag close - Zero-Lag HA(green candle) Uptrend when ZlDif is equal to or greater than zero

#uptrend {green candle}
def keep1 = if (haClose >= haOpen and haClose[1] >= haOpen[1]) then 1 else 0;
def keep2 = if ZlDif >= 0 then 1 else 0;
def keep3 = if (AbsValue(close - open) < ((high - low) * 0.35)) and high >= low[1] then 1 else 0;
def keeping = if (keep1 or keep2) then 1 else 0;
def keepall = if keeping or (keeping[1]) and close >= open or close >= (close[1]) then 1 else 0;

def utr = if keepall or (keepall[1]) and keep3 then 1 else 0;

#downtrend red candle

def keep1_ = if (haClose < haOpen and haClose[1] < haOpen[1]) then 1 else 0;
def keep2_ = if ZlDif < 0 then 1 else 0;
def keep3_ = if (AbsValue(close - open) < ((high - low) * 0.35)) and low <= high[1] then 1 else 0;
def keeping_ = if (keep1_ or keep2_) then 1 else 0;
def dkeepall_ = if keeping_ or (keeping_[1]) and close < open or close < (close[1]) then 1 else 0;

def dtr = if dkeepall_ or (dkeepall_[1] - 1) and keep3_ == 1 then 1 else 0;  #downtrend
def upw = if dtr and (dtr[1]) and utr then 1 else 0;
def dnw = if !utr and (utr[1] ) and dtr then 1 else 0;

def results = if upw then 1 else if dnw then 0 else results[1];

#Change the color of HA and Japanese Candles - turn off to show only HA on chart
AssignPriceColor(if haClose >= haOpen
                 then Color.GREEN else
                 if  haClose < haOpen
                 then Color.RED else Color.WHITE);


#Heiken_A script

#####################################################################################################
input charttype = ChartType.CANDLE;

def haopen_ = if haClose <= haOpen
              then haOpen + 0
             else Double.NaN;

def HAhi   = if haClose <= haOpen
              then haHigh
              else Double.NaN;

def HAlo =   if haClose <= haOpen
              then haLow
              else Double.NaN;


AddChart(growColor = Color.RED, neutralColor = Color.CURRENT, high = HAhi, low = HAlo, open = haopen_, close = haClose, type = ChartType.CANDLE);

def HAclose1 = ohlc4;
def HAopen1  = if haClose >= haOpen
               then CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (open[1] + close[1]) / 2)  
               else Double.NaN;

def haopen_1 = if haOpen <= haClose
               then HAopen1 + 0  else Double.NaN;

def HAhigh1  = haHigh;
def HAlow1   = haLow;


AddChart(growColor = Color.GREEN, neutralColor = Color.CURRENT,  high = HAhigh1, low = HAlow1, open = haopen_1, close = haClose, type = ChartType.CANDLE);

#####################################################################################################
#Buy and sell signals
def trend =  haClose >= haOpen;
def trendup = trend and !trend[1];
def trendd =  haClose < haOpen;
def trendDown = trendd and !trendd[1];

AddChartBubble(bubbles and trendup and trendup, HAlow1, ("Reversal:"    + round(HAlow1, 2)), Color.GREEN, no);

AddChartBubble(bubbles and trendDown and trendDown, HAhigh1, ("Reversal:"  + round(HAhigh1,2)), Color.LIGHT_RED, yes);

#Arrows instead of bubbles
#def trend = haClose >= haOpen ;
#plot trendup = trend and !trend[1];
#trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#trendup.SetDefaultColor(Color.CYAN);


#def trendd = haClose <= haOpen ;
#plot trendDown = trendd and !trendd[1];
#trendDown.SetDefaultColor(Color.MAGENTA);
#trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

I am looking forward to your feedback. Thanks.
BonBon: Can you "pretty please" create an TOS Open Shared Link for your chart scan criteria? I tried but falling short on the Relative Volume and other criteria. Thanks in advance and love your work!
 
@homeplate2 ... A fellow educator!!! As a former teacher and principal many days spent writing grants, and brainstorming ways to fund activities for students was sometimes challenging but rewarding at the same time. (to see the look on student's faces when they received new basketball uniforms, soccer equipment etc.) My colleagues and I have also started using this as a way to help our families. Now that I am at the district level, my goal is to continue supporting our families and their communities. Indeed this forum has allowed for the work to continue, especially due to the pandemic. Some of my high schools are in dire need of resources!!!!! Keep it up @homeplate2. Feel free to reach out via private message if additional assistance is needed. There are many of us out there trying to make a difference for our schools and their communities!!!!!!!
Thank you very much! I think I have a good shot at making the team and I know this stuff will help. :)
 
Sorry @Joseph Patrick 18 , I'm at a loss. Your chart looks the same as mine to me. What doesn't look like mine?
Hi RickK I solved it thanks for trying. When I put the charts one on top of the other they were almost identical the only thing was that my time was off by 30-45 minutes (weird probably on my end I had to use 3min 20D custom time frame to try to line up charts and that probably resulted in the chart shifting) so when I looked at say 9:30am on mine and your chart was identical say at 10:15am so that what was throwing me off. Sorry to bother and again thanks for your help!
Joe
 
thanks for all of this, bonbon et al. as to the watchlist, i made two minor changes, as seen below, but since we know green = +3 and red = -3, more useful than those two (redundant) numbers might be a count of the number of periods a position has been green, red or nil. when i get a moment, i'll try to figure out how to do it ...

addlabel(yes,if MTF_Above then "+3" else if MTF_Below then "-3" else if MTF_NoTrend then "NIL" else"NA", if MTF_Above then color.white else if MTF_Below then color.white else if MTF_NoTrend then color.black else color.white);
 
@floydddd ..you are welcome......I kept the +3 for the red MTF as I use this criteria for shorting stocks. (strong entry.. 3+ MTF on the short side. ). Members should edit the script to make it their own based on their trading style and trading plan.
 
@BenTen @Ilya @alexR @dominos101 @D_Tramp @Ghs @hexis777 @freedom Traders @JoeSD @AspaTrader @germanburrito @floydddd @rad14733 @barbaros @RickK @guyonabuffalo @Branch @bpVoodoo

Please see below the updates for the chart, the Fibonacci , multi time frame etc. Once again thanks for your input as mentioned previously, my goal was to obtain feedback and support from members.
Part of my strategy is no the first page (#1) and my goal was to have a simple indicator on my trade that allowed for easier entry and exits. During the past months I have been tweaking, revising, abandoning and adopting some of the scripts that I used. At this time I am "satisfied" with my results but I know I will be constantly updating looking for "perfection"

Strategy -Day and Swing Trading
First 5 gappers on scan,( gappers scan, momentum scan, low float scan etc), Low Float – under 100m shares (if a stock has momentum will consider taking the trade if it is favorable), Stocks with a strong catalyst, Market Trend -Uptrend or Downtrend ( I don't short stocks as a rule but will do so depending on the market), utilize fibonacci retracement level (look for gappers to retrace 61.8%)

Entry - Heikin Signals – confirm with volume, catalysts, multiple time frame (main plot must reflect the trend of 3 or more time frames) RSI/Stoch/SVE, market cycle etc.
Exit - Heikin signal - confirm with SVE,Stoch, MTF etc.
Stop loss - just below the Heikin reverse signal, use trailing stop and stop loss.

Now that I have adopted this indicator to be used within my trading plan, I realize my technical and fundamental knowledge helps with assessing risk/rewards even though the Heikin Smoothing trend indicator does a pretty good job of ensuring trades are profitable. After using bollinger bands, TTM Squeeze, moving averages, VWAP, Supertrend, Trendpainter etc. my profit taking is more consistent with this indicator and using the abovementioned confirmations before entering and/or exiting a trade (utilizing alerts on the chart helps as well).

Disclaimer- this is how I use the HA_smoothing indicator within my trading plan. It works for me. Everyone needs to find what works for them. This indicator is not the holy grail but I have found that combined with fundamentals and technicals it can take away some indecisiveness and keep one in the trade longer. On the flip side it can get you out of a trade and decrease the risk.

The first chart shows the updated script with less signals. The signals are based on the swing high swing low script (see below.) As you can see I have been using the new MTF with 6 timeframes. However, only 3 of them are included in the results which are shown in the top plot. When 3 or more of the timeframes are in an bullish/green it is plotted on the top chart. Similarly, the red depicts bearish trend and black neutral.

Additionally, I combined the stochastic and the SVE_Stoc_RSi into one oscillator on the lower chart. This helps identify the 123 wave pullbacks, retracement etc.

AfJEhqT.jpg


This chart shows a longer swing and has less signals. It is based on the zig zag high low script which I adapted. I mostly use this for swing trading but it works great when day trading as well.

kqXvwo7.jpg


This is the 3rd reversal script that can be used. This is another swing high swing low script that I adapted. I have experimented with all of them and based on personal preferences you can make your selection.

LsS27y2.jpg


This chart shows the HA smoothing indicator with the candles. I keep the candles as I prefer seeing the traditional movement. Eventually, having the HA smoothing indicator without the candles will become the norm. Furthermore, I am able to see the set up of the 123 wave during up or downtrends (this is also evident when using the HA smoothing indicator separately).

56Go5Mg.jpg


Here is the chart with the line instead of traditional candles.

kh9tEo2.jpg


This is my watchlist. It consists of the signals, the MTF top line which plots the trend (3 or more in a trend(bullish or bearish)), the relative volume, the SVE,Count (used to confirm the trend reversals) and the price change as of the market open. I also place which stocks can be shorted and those that cannot be shorted on my watchlist..(HTB/ETB). If markets are favorable for shorting I would do so but I seldom short stocks.

p4zCxt2.jpg


The fib lines are still a challenge. I moved the bubbles to the left and incorporated the coefficient and price together as I was not successful in shortening the lines. I am still awaiting members contribution in this area.

vybJ0Sa.jpg


Here is the updated code for the chart. Some of the bubbles and the arrows have been turned off.

Code:
#BonBon - Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update 2/1/2021, Jan 17th 2021,
#Influenced by script from HoboTheClown / blt,http://www.thinkscripter.com, TD Hacolt etc., Thinkscript Cloud, TOS & Thinkscript Collection
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price
#PLEASE DO NOT REMOVE THE HASHTAGS!!!! ONLY REMOVE THEM IF YOU PLAN ON USING THAT PARTICULAR SIGNAL. THERE ARE 3 DIFFERENT SIGNALS IN THE SCRIPT!!!!! IF YOU REMOVE ALL THE HASHTAGS YOU WILL HAVE NUMEROUS SIGNALS ON YOUR CHART!!!!!!!!!

input averagelength = 34;
input percentamount = .01;
input revAmount = .05;
input atrlength = 4;
input period = 50;
input hideCandles = no;
input show_bubble_labels = yes;
input bubbles = yes;
input arrows = yes;
input PaintBars = yes; #Update to add paintbars
input candleSmoothing = {default Valcu, Vervoort};

input movingAverageType = {default TEMA, Hull, Exponential};

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Exponential:
    openMA = CompoundValue(1, ExpAverage(open, period), open);
    closeMA = CompoundValue(1, ExpAverage(close, period), close);
    highMA = CompoundValue(1, ExpAverage(high, period), high);
    lowMA = CompoundValue(1, ExpAverage(low, period), low);
case Hull:
    openMA = CompoundValue(1, HullMovingAvg(open, period), open);
    closeMA = CompoundValue(1,  HullMovingAvg(close, period), close);
    highMA = CompoundValue(1,  HullMovingAvg(high, period), high);
    lowMA = CompoundValue(1,  HullMovingAvg(low, period), low);
case TEMA:
    openMA = CompoundValue(1, TEMA(open, period), open);
    closeMA = CompoundValue(1, TEMA(close, period), close);
    highMA = CompoundValue(1, TEMA(high, period), high);
    lowMA = CompoundValue(1, TEMA(low, period), low);
}

HidePricePlot(hideCandles);

def haOpen;
def haClose;

switch (candleSmoothing){
case Valcu:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);

case Vervoort:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0 ) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);
}

plot o = haOpen ;
o.Hide();

def haLow =  Min(lowMA, haOpen);
def haHigh = Max(highMA, haOpen);
#############################################################################################

#Medium-term price reversals - upward trend

def avg = 34;
def TMA1 = reference TEMA(haClose, avg); # triple exponential moving average (TEMA) of 34 bars
def TMA2 =  reference TEMA(TMA1, avg);
def Diff = TMA1 - TMA2;
def ZlHa = TMA1 + Diff; #Zero-lagging TEMA average on closing prices - medium term uptrend; plot line magenta
#def shortCandle = BodyHeight() < (high - low) * candleSizeFactor; #code taken from HACOLT
#Medium-term price reversals - downward trend
def avg2 = 34;
def TMA1_ = reference TEMA((high + low) / 2, avg2);
def Diff2 = TMA1_ - TMA2;
def ZlCl = TMA1_ + Diff2; #Zero-lagging TEMA average on closing prices - medium term doenwardtrend ....plot line yellow;

def ZlDif = ZlCl - ZlHa; # Zero-Lag close - Zero-Lag HA(green candle) Uptrend when ZlDif is equal to or greater than zero

#AssignPriceColor(if haclose >= haopen
               # then Color.GREEN else
                # if haclose < haopen
                # then Color.RED else color.white);

#####################################################################################################
input charttype = ChartType.CANDLE;

def haopen_ = if haClose <= haOpen
              then haOpen + 0
              else Double.NaN;

def HAhi   = if haClose <= haOpen
              then haHigh
              else Double.NaN;

def HAlo =   if haClose <= haOpen
              then haLow
              else Double.NaN;

AddChart(growColor = Color.RED, neutralColor = Color.CURRENT, high = HAhi, low = HAlo, open = haopen_, close = haClose, type = ChartType.CANDLE);

def HAclose1 = ohlc4;
def HAopen1  = if haClose >= haOpen
               then CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (open[1] + close[1]) / 2)   
               else Double.NaN;

def haopen_1 = if haOpen <= haClose
               then HAopen1 + 0  else Double.NaN;

def HAhigh1  = haHigh;
def HAlow1   = haLow;

AddChart(growColor = Color.GREEN, neutralColor = Color.CURRENT,  high = HAhigh1, low = HAlow1, open = haopen_1, close = haClose, type = ChartType.CANDLE);

#####################################################################################################
def trend = if haclose >= haopen then 1 else 0; # halow1[-50]
#plot trendup =  trend and !trend[1];
#trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#trendup.SetDefaultColor(Color.GREEN);
#trendup.SetLineWeight(5);

def Trendd =  if haclose < haopen then 1 else 0;
#plot trendDown = Trendd and !Trendd[1] ;
#trendDown.SetDefaultColor(Color.RED);
#trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#trendDown.SetLineWeight(5);

#AddChartBubble(bubbles and trendup  and trendup , HAlow1, ("R$:"  + Round(HAlow1, 2)), Color.CYAN, no);
#AddChartBubble(bubbles and trendDown and trendDown , HAhi, ("R$:"  + Round(HAhi, 2)), Color.CYAN, yes);
########################################################################
End of HA_Smoothing Script

Signals
Original code by Taz43
#updated by BonBon 1/15/21 inccreased swing_back periods, changed "high and Low to Halow1 and Hahigh1".  Included price labels/bubbles.

def bubbles2 = yes;
input swing_back = 20;
input swing_forward = 34;
input swinglow_back = 20;
input swinglow_forward =34;
input maxbars = 50;
input showlevels = Yes;
def sb = swing_back;
def sf = swing_forward;
def sb2 = swinglow_back;
def sf2 = swinglow_forward;
def na = Double.NaN;

def Offset4 =  8; # high(period = "day")and low(period = "day" ) and close(period = "day" ) * 0.03;
def bubblelocation = bubbles2[offset4];

def lfor2 = Lowest(halow, sf2)[-sf2]; #Remember that a negative number inside the square brackets means "after" this bar. So, the above line is defining "lfor" as being the lowest value of the two bars after this bar.
def lback2 = Lowest(halow, sb2)[1]; #This line of code is defining "lback" as the lowest value of the eight bars before this one.

def swinglow2 = if halow < lfor2 and halow < lback2 then 1 else 0;
#Finally, this line is actually defining what a "swing low" is. It says, if the low of this bar is lower than the two bars after this one AND the low of this bar is also lower than or equal to the lowest of the previous eight bars, then this bar is a swing low. So, what that means is that in order to determine whether a point on the chart is either a swing high or a swing low, it must have eight bars before the bar in question, as well as, two bars after it. Looking at the picture above, it can be seen that point "A" is a "swing high" because it is higher than the 8 bars before it AND it is higher than the 2 bars after it. Likewise, point "C" is a "swing low" because it is lower than the 8 bars before it AND it is lower than the 2 bars after it. (I know it's a line chart, not a bar chart. smiling smiley Just work with me here.)

plot sl = if swinglow2 then halow else na;
#sl.SetPaintingStrategy(PaintingStrategy.POINTS);
sl.SetDefaultColor(Color.WHITE);
sl.SetLineWeight(5);

def hfor = Highest(hahigh, sf)[-sf];
def hback = Highest(hahigh, sb)[1];

def swinghigh2 = if hahigh > hfor  and hahigh > hback then 1 else 0;
plot sh = if swinghigh2 then hahigh else na ;
#sh.SetDefaultColor(Color.orange);
#sh.SetPaintingStrategy(PaintingStrategy.POINTS);
sh.SetLineWeight(5);

plot fh = if swinghigh2 then hahigh else na ;
fh.SetDefaultColor(Color.magenta);
#fh.SetPaintingStrategy(PaintingStrategy.booleaN_ARROW_DOWN);
fh.SetLineWeight(5);

plot fl = if swinglow2 then halo else na;
#fl.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
fl.SetDefaultColor(Color.lime);
fl.SetLineWeight(5);

AddChartBubble(bubbles2 and fl and fl , HAlo, ("$:"  + Round(HAlo, 2)), Color.lime, no);
AddChartBubble(bubbles2 and fh and fh , HAhigh, ("$:"  + Round(HAhigh, 2)), Color.magenta, yes);
#######################################################################
Signals

###Ameritrade Thinkscript
#ZigZagHighLow High Low
#updated by BonBon 1/18/21 inccreased pivot lengths and  periods, changed "high and Low to Halow1 and Hahigh1".  Included price labels/bubbles.

def priceH = HAhigh1;
def priceL = HAlow1;
input atrreversal = 2.0;
def atr_atrreversal = atrreversal;
input tickReversal = 0;

#The minimum percentage of price change for a swing to be detected.
input percentageReversal = 5.0;
#Additional value in dollars that can be added to the minimum price change and  ATR change to increase the distance between swing points.                                  
input absoluteReversal = 0.0;
#The period for ATR calculation.
#input atrLength = 5;
#The factor by which the ATR value is multiplied.
#input atrReversal = 1.5;
#tick reversal- Additional value in ticks that can be added to the minimum price change and ATR change to increase the distance between swing points.
#input tickReversal = 0;

Assert(percentageReversal >= 0, "'percentage reversal' must not be negative: " + percentageReversal);
Assert(absoluteReversal >= 0, "'absolute reversal' must not be negative: " + absoluteReversal);
Assert(atrreversal >= 0, "'atr reversal' must not be negative: " + atrreversal);

Assert(percentageReversal != 0 or absoluteReversal != 0 or atrreversal != 0 or tickReversal != 0, "Either 'percentage reversal' or 'absolute reversal' or 'atr reversal' or 'tick reversal' must not be zero");

#Additional value in dollars that can be added to the minimum price change and  ATR change to increase the distance between swing points.                              
def absReversal;
if (absoluteReversal != 0) {
    absReversal = absoluteReversal;
} else {
    absReversal =  tickReversal * TickSize();
}

def hlPivot;
if (atrreversal != 0) {
    hlPivot = percentageReversal / 300 + WildersAverage(TrueRange(haHigh, haClose, haLow), atrlength) / haClose * atrreversal;
} else {
    hlPivot = percentageReversal / 300;
}
def state = {default init, undefined, uptrend, downtrend};
def maxPriceH;
def minPriceL;
def newMax;
def newMin;
def prevMaxH = GetValue(maxPriceH, 1);
def prevMinL = GetValue(minPriceL, 1);

if GetValue(state, 1) == GetValue(state.init, 0) {
    maxPriceH = priceH;
    minPriceL = priceL;
    newMax = yes;
    newMin = yes;
    state = state.undefined;
} else if GetValue(state, 1) == GetValue(state.undefined, 0) {
    if priceH >= prevMaxH {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = prevMinL;
        newMax = yes;
        newMin = no;
    } else if priceL <= prevMinL {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        minPriceL = priceL;
        newMax = no;
        newMin = yes;
    } else {
        state = state.undefined;
        maxPriceH = prevMaxH;
        minPriceL = prevMinL;
        newMax = no;
        newMin = no;
    }
} else if GetValue(state, 1) == GetValue(state.uptrend, 0) {
    if priceL <= prevMaxH - prevMaxH * hlPivot - absReversal {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        minPriceL = priceL;
        newMax = no;
        newMin = yes;
    } else {
        state = state.uptrend;
        if (priceH >= prevMaxH) {
            maxPriceH = priceH;
            newMax = yes;
        } else {
            maxPriceH = prevMaxH;
            newMax = no;
        }
        minPriceL = prevMinL;
        newMin = no;
    }
} else {
    if priceH >= prevMinL + prevMinL * hlPivot + absReversal {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = prevMinL;
        newMax = yes;
        newMin = no;
    } else {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        newMax = no;
        if (priceL <= prevMinL) {
            minPriceL = priceL;
            newMin = yes;
        } else {
            minPriceL = prevMinL;
            newMin = no;
        }
    }
}

def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(priceH), 0, barNumber));
def newState = GetValue(state, 0) != GetValue(state, 1);
def offset = barCount - barNumber + 1;
def highPoint = state == state.uptrend and priceH == maxPriceH;
def lowPoint = state == state.downtrend and priceL == minPriceL;

plot lastH;
if highPoint and offset > 1 {
    lastH = fold iH = 1 to offset with tH = priceH while !IsNaN(tH) and !GetValue(newState, -iH) do if GetValue(newMax, -iH) or iH == offset - 1 and GetValue(priceH, -iH) == tH then Double.NaN else tH;
} else {
    lastH = Double.NaN;
}

plot lastL;
if lowPoint and offset > 1 {
    lastL = fold iL = 1 to offset with tL = priceL while !IsNaN(tL) and !GetValue(newState, -iL) do if GetValue(newMin, -iL) or iL == offset - 1 and GetValue(priceL, -iL) == tL then Double.NaN else tL;
} else {
    lastL = Double.NaN;
}
#Zig Zag Line
#def HA;
#if barNumber == 1 {
   # HA = fold iF = 1 to offset with tP = Double.NaN while IsNaN(tP) do if GetValue(state, -iF) == #GetValue(state.uptrend, 0) then priceL else if GetValue(state, -iF) == GetValue(state.downtrend, 0) #then priceH else Double.NaN;
#} else if barNumber == barCount {
  #  HA = if highPoint or state == state.downtrend and priceL > minPriceL then priceH else if lowPoint #or state == state.uptrend and priceH < maxPriceH then priceL else Double.NaN;
#} else {
   # HA = if !IsNaN(lastH) then lastH else if !IsNaN(lastL) then lastL else Double.NaN;
#}
#HA.SetDefaultColor(GetColor(1));
#HA.EnableApproximation();

#plots up and down arrows
#lasth.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#lasth.SetDefaultColor(Color.yellow);
#lasth.SetLineWeight(5);

#lastl.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#lastl.SetDefaultColor(Color.yellow);
#lastl.SetLineWeight(5);

#AddChartBubble(bubbles and lastL and lastL, HAlow1, ("$:"  + Round(HAlow1, 2)), Color.YELLOW, no);
#AddChartBubble(bubbles and lastH and lastH, HAhigh1, ("$:"  + Round(HAhigh1, 2)), Color.YELLOW, yes);
####################################################################################
Signals

#Thinkscript cloud - Mobius/Robert Payne
#updated BonBon 1/26/2021 - changed the default settings for the swinglows.  Also changed to incorporate the HA Smoothing charttype settings.

#Here is the script for swing high and swing low. Swing high is marked by red arrow and swing low by green arrow. You can change it to dots by changing boolean_arrow_down to points. You can change the size by changing setlineweight to 2,3,4, or 5. The default setting to determine swing high/low is 3 candles but you can change that in edit properties.

input HA_swinglow = 45;
input HA_swinghigh = 45;

# define and plot the most recent high

def HA_trend = hahigh1 >= Highest(hahigh1[1],HA_swinghigh) and hahigh1 >= Highest(hahigh1[- HA_swinghigh], HA_swinghigh);
def HA_signal1 = if BarNumber() < HA_swinghigh then Double.NaN else if HA_trend then hahigh1 else Double.NaN;
plot HATrend = HA_signal1;
        #HATrend.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
        HATrend.SetDefaultColor(Color.DOWNTICK);
       HATrend.SetLineWeight(5);

# define and plot the most recent low

def HA_trend2 = halow1 <= Lowest(halow1[1],  HA_swinglow) and halow1 <= Lowest(halow1[-  HA_swinglow],  HA_swinglow);
def HA_signal2 = if BarNumber() <  HA_swinglow then Double.NaN else if HA_trend2 then halow1 else Double.NaN;
plot HATrend2 = HA_signal2;
      # HATrend2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
       # HATrend2.SetDefaultColor(Color.UPTICK);
       # HATrend2.SetLineWeight(5);

#AddChartBubble(bubbles and HATrend2 and HATrend2, HAlow1, ("$:"  + Round(HAlow1, 2)), Color.lime, no);
#AddChartBubble(bubbles and HATrend and HATrend, HAhigh1, ("$:"  + Round(HAhigh1, 2)), Color.magenta, yes);

#End code
#################################################

Multi-Time Frame Script for the lower chart

# Multi time-frame Heikin
#BonBon 1/29/21
#  Four hours and Day MTF not included in the top plot. Three or more of the indicators must be green or red to plot.


declare lower;

input UsePeriod5 = AggregationPeriod.FIVE_MIN;
input UsePeriod15 = AggregationPeriod.FIFTEEN_MIN;
input UsePeriod30 = AggregationPeriod.thirty_MIN;
input UsePeriod60 = AggregationPeriod. HOUR;
input UsePeriod4hr = AggregationPeriod. FOUR_HOURS;
input UsePeriodday = AggregationPeriod.DAY;

input  Con_Cri = 3;

input Main_Heikin_Plot = Yes;


#Timeframe1 5 min

def aOpen5 = open(period = UsePeriod5);
def aClose5 = close(period = UsePeriod5);
def aHigh5 = high(period = UsePeriod5);
def aLow5 = low(period = UsePeriod5);

def haClose5 = (aOpen5 + aClose5 + aHigh5 + aLow5) / 4;
def haOpen5 = (haOpen5[1] + haClose5[1]) / 2;

def trend5 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
plot HA_Up5 = if IsNaN(UsePeriod5) then Double.NaN else 6;
HA_Up5.SetPaintingStrategy(PaintingStrategy.POINTS);#SetStyle(curve.Points);
HA_Up5.AssignValueColor(if haClose5 >= haOpen5 then Color.GREEN else if haClose5[1] < haOpen5[1] then Color.RED else Color.CURRENT);
HA_Up5.SetLineWeight(4);
############################################

#Timeframe2 15 mins

def aOpen15 = open(period = UsePeriod15);
def aClose15 = close(period = UsePeriod15);
def aHigh15 = high(period = UsePeriod15);
def aLow15 = low(period = UsePeriod15);

def haClose15 = (aOpen15 + aClose15 + aHigh15 + aLow15) / 4;
def haOpen15 = (haOpen15[1] + haClose15[1]) / 2;


def trend15 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
plot HA_Up15 = if IsNaN(UsePeriod15) then Double.NaN else 5;
#plot HA_Up15 = if haClose15 >= haOpen15 then 1 else 0;
HA_Up15.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up15.AssignValueColor(if haClose15 >= haOpen15 then Color.GREEN else if haClose15 [1]< haOpen15[1] then Color.RED else Color.CURRENT);
HA_Up15.SetLineWeight(4);
#######################################

#Timeframe3  30 mins

def aOpen30 = open(period = UsePeriod30);
def aClose30 = close(period = UsePeriod30);
def aHigh30 = high(period = UsePeriod30);
def aLow30 = low(period = UsePeriod30);

def haClose30 = (aOpen30 + aClose30 + aHigh30 + aLow30) / 4;
def haOpen30 = (haOpen30[1] + haClose30[1]) / 2;


def trend30 = if haClose30 >= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
plot HA_Up30 = if IsNaN(UsePeriod30) then Double.NaN else 4;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up30.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up30.AssignValueColor(if haClose30 >= haOpen30 then Color.GREEN else if haClose30[1] < haOpen30[1] then Color.RED else Color.CURRENT);
HA_Up30.SetLineWeight(4);

################################
#Timeframe4  60mins

def aOpen60 = open(period = UsePeriod60);
def aClose60 = close(period = UsePeriod60);
def aHigh60 = high(period = UsePeriod60);
def aLow60 = low(period = UsePeriod60);

def haClose60 = (aOpen60 + aClose60 + aHigh60 + aLow60) / 4;
def haOpen60 = (haOpen60[1] + haClose60[1]) / 2;

def trend60 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
plot HA_Up60 = if IsNaN(UsePeriod60) then Double.NaN else 3;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up60.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up60.AssignValueColor(if haClose60 >= haOpen60 then Color.GREEN else if haClose60[1] < haOpen60[1] then Color.RED else Color.CURRENT);
HA_Up60.SetLineWeight(4);

##################################
#Timeframe5 4hrs

def aOpen4hr = open(period = UsePeriod4hr);
def aClose4hr = close(period = UsePeriod4hr);
def aHigh4hr = high(period = UsePeriod4hr);
def aLow4hr = low(period = UsePeriod4hr);

def haClose4hr = (aOpen4hr + aClose4hr + aHigh4hr + aLow4hr) / 4;
def haOpen4hr = (haOpen4hr[1] + haClose4hr[1]) / 2;

def trend4hr = if haClose4hr >= haOpen4hr then 1 else if haClose4hr < haOpen4hr then -1 else 0;
plot HA_Up4hr = if IsNaN(UsePeriod4hr) then Double.NaN else 2;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up4hr.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up4hr.AssignValueColor(if haClose4hr >= haOpen4hr then Color.GREEN else if haClose4hr[1] < haOpen4hr[1] then Color.RED else Color.CURRENT);
HA_Up4hr.SetLineWeight(4);
#######################################

#Timeframe6 Day

def aOpenday = open(period = UsePeriodday);
def aCloseday = close(period = UsePeriodday);
def aHighday = high(period = UsePeriodday);
def aLowday = low(period = UsePeriodday);

def haCloseday = (aOpenday + aCloseday + aHighday + aLowday) / 4;
def haOpenday = (haOpenday[1] + haCloseday[1]) / 2;

def trendday = if haCloseday >= haOpenday then 1 else if haCloseday [1] < haOpenday[1] then -1 else 0;
plot HA_Upday = if IsNaN(UsePeriodday) then Double.NaN else 1;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Upday.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Upday.AssignValueColor(if haCloseday >= haOpenday then Color.GREEN else if haCloseday[1] < haOpenday[1] then Color.RED else Color.CURRENT);
HA_Upday.SetLineWeight(4);

####################################
#def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
#def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
#def Trend3 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
#def Trend4 = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
#def Trend5_ = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
#def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
#def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
#def Trend3c = if haClose60 < haOpen60  then 1 else if haClose60[1]>= haOpen60[1] then -1 else 0;
#def Trend4d = if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
#def Trend5e = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#Up Trend
def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
def Trend3 = if haClose30>= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
def Trend4 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
def Trend5_ = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
def Trend6 = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
def Trend3c = if haClose30 < haOpen30 then 1 else if haClose30[1] >= haOpen30[1] then -1 else 0;
def Trend4d = if haClose60 < haOpen60  then 1 else if haClose60[1] >= haOpen60[1] then -1 else 0;
def Trend5e= if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
def Trend6f = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#plot MTF_TREND = 6;
#MTF_TREND.SetPaintingStrategy(PaintingStrategy.Points);
#MTF_TREND.SetLineWeight(lineWeight = 3);
#MTF_TREND.DefineColor("Buy", GetColor(5));
#MTF_TREND.DefineColor("Sell", GetColor(6));
#MTF_TREND.AssignValueColor(if (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 then Color.GREEN else Color.RED);

#MTF_TREND.AssignValueColor(if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 #then Color.GREEN else if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) < 3 then #Color. RED else Color.CURRENT);

def HA_MTF_TrendUP = (Trend1 + Trend2 + Trend3 + Trend4) >=  Con_Cri ;
def HA_MTF_TrendDN = (Trend1a + Trend2b + Trend3c + Trend4d) >=  Con_Cri;

plot Main_Heikin = 7;
Main_Heikin.SetPaintingStrategy(PaintingStrategy.POINTS);
Main_Heikin.AssignValueColor(if HA_MTF_TrendUP == 1 then Color.Green else if HA_MTF_TrendDN == 1 then color.red else Color.Black);
Main_Heikin.SetLineWeight(4);

#End code
#######################################################
I'm a rookie here.... how did you make that watchlist? How do you get the colors and icons? That's awesome, I'd like that! Thank you.
 
@BenTen @Ilya @alexR @dominos101 @D_Tramp @Ghs @hexis777 @freedom Traders @JoeSD @AspaTrader @germanburrito @floydddd @rad14733 @barbaros @RickK @guyonabuffalo @Branch @bpVoodoo

Please see below the updates for the chart, the Fibonacci , multi time frame etc. Once again thanks for your input as mentioned previously, my goal was to obtain feedback and support from members.
Part of my strategy is no the first page (#1) and my goal was to have a simple indicator on my trade that allowed for easier entry and exits. During the past months I have been tweaking, revising, abandoning and adopting some of the scripts that I used. At this time I am "satisfied" with my results but I know I will be constantly updating looking for "perfection"

Strategy -Day and Swing Trading
First 5 gappers on scan,( gappers scan, momentum scan, low float scan etc), Low Float – under 100m shares (if a stock has momentum will consider taking the trade if it is favorable), Stocks with a strong catalyst, Market Trend -Uptrend or Downtrend ( I don't short stocks as a rule but will do so depending on the market), utilize fibonacci retracement level (look for gappers to retrace 61.8%)

Entry - Heikin Signals – confirm with volume, catalysts, multiple time frame (main plot must reflect the trend of 3 or more time frames) RSI/Stoch/SVE, market cycle etc.
Exit - Heikin signal - confirm with SVE,Stoch, MTF etc.
Stop loss - just below the Heikin reverse signal, use trailing stop and stop loss.

Now that I have adopted this indicator to be used within my trading plan, I realize my technical and fundamental knowledge helps with assessing risk/rewards even though the Heikin Smoothing trend indicator does a pretty good job of ensuring trades are profitable. After using bollinger bands, TTM Squeeze, moving averages, VWAP, Supertrend, Trendpainter etc. my profit taking is more consistent with this indicator and using the abovementioned confirmations before entering and/or exiting a trade (utilizing alerts on the chart helps as well).

Disclaimer- this is how I use the HA_smoothing indicator within my trading plan. It works for me. Everyone needs to find what works for them. This indicator is not the holy grail but I have found that combined with fundamentals and technicals it can take away some indecisiveness and keep one in the trade longer. On the flip side it can get you out of a trade and decrease the risk.

The first chart shows the updated script with less signals. The signals are based on the swing high swing low script (see below.) As you can see I have been using the new MTF with 6 timeframes. However, only 3 of them are included in the results which are shown in the top plot. When 3 or more of the timeframes are in an bullish/green it is plotted on the top chart. Similarly, the red depicts bearish trend and black neutral.

Additionally, I combined the stochastic and the SVE_Stoc_RSi into one oscillator on the lower chart. This helps identify the 123 wave pullbacks, retracement etc.

AfJEhqT.jpg


This chart shows a longer swing and has less signals. It is based on the zig zag high low script which I adapted. I mostly use this for swing trading but it works great when day trading as well.

kqXvwo7.jpg


This is the 3rd reversal script that can be used. This is another swing high swing low script that I adapted. I have experimented with all of them and based on personal preferences you can make your selection.

LsS27y2.jpg


This chart shows the HA smoothing indicator with the candles. I keep the candles as I prefer seeing the traditional movement. Eventually, having the HA smoothing indicator without the candles will become the norm. Furthermore, I am able to see the set up of the 123 wave during up or downtrends (this is also evident when using the HA smoothing indicator separately).

56Go5Mg.jpg


Here is the chart with the line instead of traditional candles.

kh9tEo2.jpg


This is my watchlist. It consists of the signals, the MTF top line which plots the trend (3 or more in a trend(bullish or bearish)), the relative volume, the SVE,Count (used to confirm the trend reversals) and the price change as of the market open. I also place which stocks can be shorted and those that cannot be shorted on my watchlist..(HTB/ETB). If markets are favorable for shorting I would do so but I seldom short stocks.

p4zCxt2.jpg


The fib lines are still a challenge. I moved the bubbles to the left and incorporated the coefficient and price together as I was not successful in shortening the lines. I am still awaiting members contribution in this area.

vybJ0Sa.jpg


Here is the updated code for the chart. Some of the bubbles and the arrows have been turned off.

Code:
#BonBon - Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update 2/1/2021, Jan 17th 2021,
#Influenced by script from HoboTheClown / blt,http://www.thinkscripter.com, TD Hacolt etc., Thinkscript Cloud, TOS & Thinkscript Collection
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price
#PLEASE DO NOT REMOVE THE HASHTAGS!!!! ONLY REMOVE THEM IF YOU PLAN ON USING THAT PARTICULAR SIGNAL. THERE ARE 3 DIFFERENT SIGNALS IN THE SCRIPT!!!!! IF YOU REMOVE ALL THE HASHTAGS YOU WILL HAVE NUMEROUS SIGNALS ON YOUR CHART!!!!!!!!!

input averagelength = 34;
input percentamount = .01;
input revAmount = .05;
input atrlength = 4;
input period = 50;
input hideCandles = no;
input show_bubble_labels = yes;
input bubbles = yes;
input arrows = yes;
input PaintBars = yes; #Update to add paintbars
input candleSmoothing = {default Valcu, Vervoort};

input movingAverageType = {default TEMA, Hull, Exponential};

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Exponential:
    openMA = CompoundValue(1, ExpAverage(open, period), open);
    closeMA = CompoundValue(1, ExpAverage(close, period), close);
    highMA = CompoundValue(1, ExpAverage(high, period), high);
    lowMA = CompoundValue(1, ExpAverage(low, period), low);
case Hull:
    openMA = CompoundValue(1, HullMovingAvg(open, period), open);
    closeMA = CompoundValue(1,  HullMovingAvg(close, period), close);
    highMA = CompoundValue(1,  HullMovingAvg(high, period), high);
    lowMA = CompoundValue(1,  HullMovingAvg(low, period), low);
case TEMA:
    openMA = CompoundValue(1, TEMA(open, period), open);
    closeMA = CompoundValue(1, TEMA(close, period), close);
    highMA = CompoundValue(1, TEMA(high, period), high);
    lowMA = CompoundValue(1, TEMA(low, period), low);
}

HidePricePlot(hideCandles);

def haOpen;
def haClose;

switch (candleSmoothing){
case Valcu:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);

case Vervoort:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0 ) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);
}

plot o = haOpen ;
o.Hide();

def haLow =  Min(lowMA, haOpen);
def haHigh = Max(highMA, haOpen);
#############################################################################################

#Medium-term price reversals - upward trend

def avg = 34;
def TMA1 = reference TEMA(haClose, avg); # triple exponential moving average (TEMA) of 34 bars
def TMA2 =  reference TEMA(TMA1, avg);
def Diff = TMA1 - TMA2;
def ZlHa = TMA1 + Diff; #Zero-lagging TEMA average on closing prices - medium term uptrend; plot line magenta
#def shortCandle = BodyHeight() < (high - low) * candleSizeFactor; #code taken from HACOLT
#Medium-term price reversals - downward trend
def avg2 = 34;
def TMA1_ = reference TEMA((high + low) / 2, avg2);
def Diff2 = TMA1_ - TMA2;
def ZlCl = TMA1_ + Diff2; #Zero-lagging TEMA average on closing prices - medium term doenwardtrend ....plot line yellow;

def ZlDif = ZlCl - ZlHa; # Zero-Lag close - Zero-Lag HA(green candle) Uptrend when ZlDif is equal to or greater than zero

#AssignPriceColor(if haclose >= haopen
               # then Color.GREEN else
                # if haclose < haopen
                # then Color.RED else color.white);

#####################################################################################################
input charttype = ChartType.CANDLE;

def haopen_ = if haClose <= haOpen
              then haOpen + 0
              else Double.NaN;

def HAhi   = if haClose <= haOpen
              then haHigh
              else Double.NaN;

def HAlo =   if haClose <= haOpen
              then haLow
              else Double.NaN;

AddChart(growColor = Color.RED, neutralColor = Color.CURRENT, high = HAhi, low = HAlo, open = haopen_, close = haClose, type = ChartType.CANDLE);

def HAclose1 = ohlc4;
def HAopen1  = if haClose >= haOpen
               then CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (open[1] + close[1]) / 2)   
               else Double.NaN;

def haopen_1 = if haOpen <= haClose
               then HAopen1 + 0  else Double.NaN;

def HAhigh1  = haHigh;
def HAlow1   = haLow;

AddChart(growColor = Color.GREEN, neutralColor = Color.CURRENT,  high = HAhigh1, low = HAlow1, open = haopen_1, close = haClose, type = ChartType.CANDLE);

#####################################################################################################
def trend = if haclose >= haopen then 1 else 0; # halow1[-50]
#plot trendup =  trend and !trend[1];
#trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#trendup.SetDefaultColor(Color.GREEN);
#trendup.SetLineWeight(5);

def Trendd =  if haclose < haopen then 1 else 0;
#plot trendDown = Trendd and !Trendd[1] ;
#trendDown.SetDefaultColor(Color.RED);
#trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#trendDown.SetLineWeight(5);

#AddChartBubble(bubbles and trendup  and trendup , HAlow1, ("R$:"  + Round(HAlow1, 2)), Color.CYAN, no);
#AddChartBubble(bubbles and trendDown and trendDown , HAhi, ("R$:"  + Round(HAhi, 2)), Color.CYAN, yes);
########################################################################
End of HA_Smoothing Script

Signals
Original code by Taz43
#updated by BonBon 1/15/21 inccreased swing_back periods, changed "high and Low to Halow1 and Hahigh1".  Included price labels/bubbles.

def bubbles2 = yes;
input swing_back = 20;
input swing_forward = 34;
input swinglow_back = 20;
input swinglow_forward =34;
input maxbars = 50;
input showlevels = Yes;
def sb = swing_back;
def sf = swing_forward;
def sb2 = swinglow_back;
def sf2 = swinglow_forward;
def na = Double.NaN;

def Offset4 =  8; # high(period = "day")and low(period = "day" ) and close(period = "day" ) * 0.03;
def bubblelocation = bubbles2[offset4];

def lfor2 = Lowest(halow, sf2)[-sf2]; #Remember that a negative number inside the square brackets means "after" this bar. So, the above line is defining "lfor" as being the lowest value of the two bars after this bar.
def lback2 = Lowest(halow, sb2)[1]; #This line of code is defining "lback" as the lowest value of the eight bars before this one.

def swinglow2 = if halow < lfor2 and halow < lback2 then 1 else 0;
#Finally, this line is actually defining what a "swing low" is. It says, if the low of this bar is lower than the two bars after this one AND the low of this bar is also lower than or equal to the lowest of the previous eight bars, then this bar is a swing low. So, what that means is that in order to determine whether a point on the chart is either a swing high or a swing low, it must have eight bars before the bar in question, as well as, two bars after it. Looking at the picture above, it can be seen that point "A" is a "swing high" because it is higher than the 8 bars before it AND it is higher than the 2 bars after it. Likewise, point "C" is a "swing low" because it is lower than the 8 bars before it AND it is lower than the 2 bars after it. (I know it's a line chart, not a bar chart. smiling smiley Just work with me here.)

plot sl = if swinglow2 then halow else na;
#sl.SetPaintingStrategy(PaintingStrategy.POINTS);
sl.SetDefaultColor(Color.WHITE);
sl.SetLineWeight(5);

def hfor = Highest(hahigh, sf)[-sf];
def hback = Highest(hahigh, sb)[1];

def swinghigh2 = if hahigh > hfor  and hahigh > hback then 1 else 0;
plot sh = if swinghigh2 then hahigh else na ;
#sh.SetDefaultColor(Color.orange);
#sh.SetPaintingStrategy(PaintingStrategy.POINTS);
sh.SetLineWeight(5);

plot fh = if swinghigh2 then hahigh else na ;
fh.SetDefaultColor(Color.magenta);
#fh.SetPaintingStrategy(PaintingStrategy.booleaN_ARROW_DOWN);
fh.SetLineWeight(5);

plot fl = if swinglow2 then halo else na;
#fl.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
fl.SetDefaultColor(Color.lime);
fl.SetLineWeight(5);

AddChartBubble(bubbles2 and fl and fl , HAlo, ("$:"  + Round(HAlo, 2)), Color.lime, no);
AddChartBubble(bubbles2 and fh and fh , HAhigh, ("$:"  + Round(HAhigh, 2)), Color.magenta, yes);
#######################################################################
Signals

###Ameritrade Thinkscript
#ZigZagHighLow High Low
#updated by BonBon 1/18/21 inccreased pivot lengths and  periods, changed "high and Low to Halow1 and Hahigh1".  Included price labels/bubbles.

def priceH = HAhigh1;
def priceL = HAlow1;
input atrreversal = 2.0;
def atr_atrreversal = atrreversal;
input tickReversal = 0;

#The minimum percentage of price change for a swing to be detected.
input percentageReversal = 5.0;
#Additional value in dollars that can be added to the minimum price change and  ATR change to increase the distance between swing points.                                  
input absoluteReversal = 0.0;
#The period for ATR calculation.
#input atrLength = 5;
#The factor by which the ATR value is multiplied.
#input atrReversal = 1.5;
#tick reversal- Additional value in ticks that can be added to the minimum price change and ATR change to increase the distance between swing points.
#input tickReversal = 0;

Assert(percentageReversal >= 0, "'percentage reversal' must not be negative: " + percentageReversal);
Assert(absoluteReversal >= 0, "'absolute reversal' must not be negative: " + absoluteReversal);
Assert(atrreversal >= 0, "'atr reversal' must not be negative: " + atrreversal);

Assert(percentageReversal != 0 or absoluteReversal != 0 or atrreversal != 0 or tickReversal != 0, "Either 'percentage reversal' or 'absolute reversal' or 'atr reversal' or 'tick reversal' must not be zero");

#Additional value in dollars that can be added to the minimum price change and  ATR change to increase the distance between swing points.                              
def absReversal;
if (absoluteReversal != 0) {
    absReversal = absoluteReversal;
} else {
    absReversal =  tickReversal * TickSize();
}

def hlPivot;
if (atrreversal != 0) {
    hlPivot = percentageReversal / 300 + WildersAverage(TrueRange(haHigh, haClose, haLow), atrlength) / haClose * atrreversal;
} else {
    hlPivot = percentageReversal / 300;
}
def state = {default init, undefined, uptrend, downtrend};
def maxPriceH;
def minPriceL;
def newMax;
def newMin;
def prevMaxH = GetValue(maxPriceH, 1);
def prevMinL = GetValue(minPriceL, 1);

if GetValue(state, 1) == GetValue(state.init, 0) {
    maxPriceH = priceH;
    minPriceL = priceL;
    newMax = yes;
    newMin = yes;
    state = state.undefined;
} else if GetValue(state, 1) == GetValue(state.undefined, 0) {
    if priceH >= prevMaxH {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = prevMinL;
        newMax = yes;
        newMin = no;
    } else if priceL <= prevMinL {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        minPriceL = priceL;
        newMax = no;
        newMin = yes;
    } else {
        state = state.undefined;
        maxPriceH = prevMaxH;
        minPriceL = prevMinL;
        newMax = no;
        newMin = no;
    }
} else if GetValue(state, 1) == GetValue(state.uptrend, 0) {
    if priceL <= prevMaxH - prevMaxH * hlPivot - absReversal {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        minPriceL = priceL;
        newMax = no;
        newMin = yes;
    } else {
        state = state.uptrend;
        if (priceH >= prevMaxH) {
            maxPriceH = priceH;
            newMax = yes;
        } else {
            maxPriceH = prevMaxH;
            newMax = no;
        }
        minPriceL = prevMinL;
        newMin = no;
    }
} else {
    if priceH >= prevMinL + prevMinL * hlPivot + absReversal {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = prevMinL;
        newMax = yes;
        newMin = no;
    } else {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        newMax = no;
        if (priceL <= prevMinL) {
            minPriceL = priceL;
            newMin = yes;
        } else {
            minPriceL = prevMinL;
            newMin = no;
        }
    }
}

def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(priceH), 0, barNumber));
def newState = GetValue(state, 0) != GetValue(state, 1);
def offset = barCount - barNumber + 1;
def highPoint = state == state.uptrend and priceH == maxPriceH;
def lowPoint = state == state.downtrend and priceL == minPriceL;

plot lastH;
if highPoint and offset > 1 {
    lastH = fold iH = 1 to offset with tH = priceH while !IsNaN(tH) and !GetValue(newState, -iH) do if GetValue(newMax, -iH) or iH == offset - 1 and GetValue(priceH, -iH) == tH then Double.NaN else tH;
} else {
    lastH = Double.NaN;
}

plot lastL;
if lowPoint and offset > 1 {
    lastL = fold iL = 1 to offset with tL = priceL while !IsNaN(tL) and !GetValue(newState, -iL) do if GetValue(newMin, -iL) or iL == offset - 1 and GetValue(priceL, -iL) == tL then Double.NaN else tL;
} else {
    lastL = Double.NaN;
}
#Zig Zag Line
#def HA;
#if barNumber == 1 {
   # HA = fold iF = 1 to offset with tP = Double.NaN while IsNaN(tP) do if GetValue(state, -iF) == #GetValue(state.uptrend, 0) then priceL else if GetValue(state, -iF) == GetValue(state.downtrend, 0) #then priceH else Double.NaN;
#} else if barNumber == barCount {
  #  HA = if highPoint or state == state.downtrend and priceL > minPriceL then priceH else if lowPoint #or state == state.uptrend and priceH < maxPriceH then priceL else Double.NaN;
#} else {
   # HA = if !IsNaN(lastH) then lastH else if !IsNaN(lastL) then lastL else Double.NaN;
#}
#HA.SetDefaultColor(GetColor(1));
#HA.EnableApproximation();

#plots up and down arrows
#lasth.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#lasth.SetDefaultColor(Color.yellow);
#lasth.SetLineWeight(5);

#lastl.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#lastl.SetDefaultColor(Color.yellow);
#lastl.SetLineWeight(5);

#AddChartBubble(bubbles and lastL and lastL, HAlow1, ("$:"  + Round(HAlow1, 2)), Color.YELLOW, no);
#AddChartBubble(bubbles and lastH and lastH, HAhigh1, ("$:"  + Round(HAhigh1, 2)), Color.YELLOW, yes);
####################################################################################
Signals

#Thinkscript cloud - Mobius/Robert Payne
#updated BonBon 1/26/2021 - changed the default settings for the swinglows.  Also changed to incorporate the HA Smoothing charttype settings.

#Here is the script for swing high and swing low. Swing high is marked by red arrow and swing low by green arrow. You can change it to dots by changing boolean_arrow_down to points. You can change the size by changing setlineweight to 2,3,4, or 5. The default setting to determine swing high/low is 3 candles but you can change that in edit properties.

input HA_swinglow = 45;
input HA_swinghigh = 45;

# define and plot the most recent high

def HA_trend = hahigh1 >= Highest(hahigh1[1],HA_swinghigh) and hahigh1 >= Highest(hahigh1[- HA_swinghigh], HA_swinghigh);
def HA_signal1 = if BarNumber() < HA_swinghigh then Double.NaN else if HA_trend then hahigh1 else Double.NaN;
plot HATrend = HA_signal1;
        #HATrend.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
        HATrend.SetDefaultColor(Color.DOWNTICK);
       HATrend.SetLineWeight(5);

# define and plot the most recent low

def HA_trend2 = halow1 <= Lowest(halow1[1],  HA_swinglow) and halow1 <= Lowest(halow1[-  HA_swinglow],  HA_swinglow);
def HA_signal2 = if BarNumber() <  HA_swinglow then Double.NaN else if HA_trend2 then halow1 else Double.NaN;
plot HATrend2 = HA_signal2;
      # HATrend2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
       # HATrend2.SetDefaultColor(Color.UPTICK);
       # HATrend2.SetLineWeight(5);

#AddChartBubble(bubbles and HATrend2 and HATrend2, HAlow1, ("$:"  + Round(HAlow1, 2)), Color.lime, no);
#AddChartBubble(bubbles and HATrend and HATrend, HAhigh1, ("$:"  + Round(HAhigh1, 2)), Color.magenta, yes);

#End code
#################################################

Multi-Time Frame Script for the lower chart

# Multi time-frame Heikin
#BonBon 1/29/21
#  Four hours and Day MTF not included in the top plot. Three or more of the indicators must be green or red to plot.


declare lower;

input UsePeriod5 = AggregationPeriod.FIVE_MIN;
input UsePeriod15 = AggregationPeriod.FIFTEEN_MIN;
input UsePeriod30 = AggregationPeriod.thirty_MIN;
input UsePeriod60 = AggregationPeriod. HOUR;
input UsePeriod4hr = AggregationPeriod. FOUR_HOURS;
input UsePeriodday = AggregationPeriod.DAY;

input  Con_Cri = 3;

input Main_Heikin_Plot = Yes;


#Timeframe1 5 min

def aOpen5 = open(period = UsePeriod5);
def aClose5 = close(period = UsePeriod5);
def aHigh5 = high(period = UsePeriod5);
def aLow5 = low(period = UsePeriod5);

def haClose5 = (aOpen5 + aClose5 + aHigh5 + aLow5) / 4;
def haOpen5 = (haOpen5[1] + haClose5[1]) / 2;

def trend5 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
plot HA_Up5 = if IsNaN(UsePeriod5) then Double.NaN else 6;
HA_Up5.SetPaintingStrategy(PaintingStrategy.POINTS);#SetStyle(curve.Points);
HA_Up5.AssignValueColor(if haClose5 >= haOpen5 then Color.GREEN else if haClose5[1] < haOpen5[1] then Color.RED else Color.CURRENT);
HA_Up5.SetLineWeight(4);
############################################

#Timeframe2 15 mins

def aOpen15 = open(period = UsePeriod15);
def aClose15 = close(period = UsePeriod15);
def aHigh15 = high(period = UsePeriod15);
def aLow15 = low(period = UsePeriod15);

def haClose15 = (aOpen15 + aClose15 + aHigh15 + aLow15) / 4;
def haOpen15 = (haOpen15[1] + haClose15[1]) / 2;


def trend15 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
plot HA_Up15 = if IsNaN(UsePeriod15) then Double.NaN else 5;
#plot HA_Up15 = if haClose15 >= haOpen15 then 1 else 0;
HA_Up15.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up15.AssignValueColor(if haClose15 >= haOpen15 then Color.GREEN else if haClose15 [1]< haOpen15[1] then Color.RED else Color.CURRENT);
HA_Up15.SetLineWeight(4);
#######################################

#Timeframe3  30 mins

def aOpen30 = open(period = UsePeriod30);
def aClose30 = close(period = UsePeriod30);
def aHigh30 = high(period = UsePeriod30);
def aLow30 = low(period = UsePeriod30);

def haClose30 = (aOpen30 + aClose30 + aHigh30 + aLow30) / 4;
def haOpen30 = (haOpen30[1] + haClose30[1]) / 2;


def trend30 = if haClose30 >= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
plot HA_Up30 = if IsNaN(UsePeriod30) then Double.NaN else 4;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up30.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up30.AssignValueColor(if haClose30 >= haOpen30 then Color.GREEN else if haClose30[1] < haOpen30[1] then Color.RED else Color.CURRENT);
HA_Up30.SetLineWeight(4);

################################
#Timeframe4  60mins

def aOpen60 = open(period = UsePeriod60);
def aClose60 = close(period = UsePeriod60);
def aHigh60 = high(period = UsePeriod60);
def aLow60 = low(period = UsePeriod60);

def haClose60 = (aOpen60 + aClose60 + aHigh60 + aLow60) / 4;
def haOpen60 = (haOpen60[1] + haClose60[1]) / 2;

def trend60 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
plot HA_Up60 = if IsNaN(UsePeriod60) then Double.NaN else 3;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up60.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up60.AssignValueColor(if haClose60 >= haOpen60 then Color.GREEN else if haClose60[1] < haOpen60[1] then Color.RED else Color.CURRENT);
HA_Up60.SetLineWeight(4);

##################################
#Timeframe5 4hrs

def aOpen4hr = open(period = UsePeriod4hr);
def aClose4hr = close(period = UsePeriod4hr);
def aHigh4hr = high(period = UsePeriod4hr);
def aLow4hr = low(period = UsePeriod4hr);

def haClose4hr = (aOpen4hr + aClose4hr + aHigh4hr + aLow4hr) / 4;
def haOpen4hr = (haOpen4hr[1] + haClose4hr[1]) / 2;

def trend4hr = if haClose4hr >= haOpen4hr then 1 else if haClose4hr < haOpen4hr then -1 else 0;
plot HA_Up4hr = if IsNaN(UsePeriod4hr) then Double.NaN else 2;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up4hr.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up4hr.AssignValueColor(if haClose4hr >= haOpen4hr then Color.GREEN else if haClose4hr[1] < haOpen4hr[1] then Color.RED else Color.CURRENT);
HA_Up4hr.SetLineWeight(4);
#######################################

#Timeframe6 Day

def aOpenday = open(period = UsePeriodday);
def aCloseday = close(period = UsePeriodday);
def aHighday = high(period = UsePeriodday);
def aLowday = low(period = UsePeriodday);

def haCloseday = (aOpenday + aCloseday + aHighday + aLowday) / 4;
def haOpenday = (haOpenday[1] + haCloseday[1]) / 2;

def trendday = if haCloseday >= haOpenday then 1 else if haCloseday [1] < haOpenday[1] then -1 else 0;
plot HA_Upday = if IsNaN(UsePeriodday) then Double.NaN else 1;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Upday.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Upday.AssignValueColor(if haCloseday >= haOpenday then Color.GREEN else if haCloseday[1] < haOpenday[1] then Color.RED else Color.CURRENT);
HA_Upday.SetLineWeight(4);

####################################
#def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
#def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
#def Trend3 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
#def Trend4 = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
#def Trend5_ = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
#def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
#def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
#def Trend3c = if haClose60 < haOpen60  then 1 else if haClose60[1]>= haOpen60[1] then -1 else 0;
#def Trend4d = if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
#def Trend5e = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#Up Trend
def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
def Trend3 = if haClose30>= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
def Trend4 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
def Trend5_ = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
def Trend6 = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
def Trend3c = if haClose30 < haOpen30 then 1 else if haClose30[1] >= haOpen30[1] then -1 else 0;
def Trend4d = if haClose60 < haOpen60  then 1 else if haClose60[1] >= haOpen60[1] then -1 else 0;
def Trend5e= if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
def Trend6f = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#plot MTF_TREND = 6;
#MTF_TREND.SetPaintingStrategy(PaintingStrategy.Points);
#MTF_TREND.SetLineWeight(lineWeight = 3);
#MTF_TREND.DefineColor("Buy", GetColor(5));
#MTF_TREND.DefineColor("Sell", GetColor(6));
#MTF_TREND.AssignValueColor(if (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 then Color.GREEN else Color.RED);

#MTF_TREND.AssignValueColor(if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 #then Color.GREEN else if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) < 3 then #Color. RED else Color.CURRENT);

def HA_MTF_TrendUP = (Trend1 + Trend2 + Trend3 + Trend4) >=  Con_Cri ;
def HA_MTF_TrendDN = (Trend1a + Trend2b + Trend3c + Trend4d) >=  Con_Cri;

plot Main_Heikin = 7;
Main_Heikin.SetPaintingStrategy(PaintingStrategy.POINTS);
Main_Heikin.AssignValueColor(if HA_MTF_TrendUP == 1 then Color.Green else if HA_MTF_TrendDN == 1 then color.red else Color.Black);
Main_Heikin.SetLineWeight(4);

#End code
#######################################################
The Editor is telling me I have an Invalid statement: End at 134:1 and Signals at 189:1 350:1 and Multi at 384:1
 
Here is the scan for the Fibonacci Retracement. The scan will look for stocks based on the criteria where the price crosses below the 61.8% and 78.6% before gapping up. Members can change the criteria based on their trading plan etc. The below code can be added as a study on the custom scan or the plot scan script can be added to the chart study and accessed from the scan tab. My personal preference is to create a separate scan instead of adding to the study.

Code:
#Created by RyanHendricks.
#Modified by #BonBon Feb 2020#BonBon changed the color of trendlines and added the price to the fibFan percentage
#BonBon updated Feb 2020 created a scan that will look for stocks based on the criteria - price crosses below the 61.8% and 78.6% before gapping up.

#hint: <b>Fibonacci Retracements</b>\nFibonacci retracements use horizontal lines to indicate areas of support or resistance at the key Fibonacci levels before it continues in the original direction. These levels are created by drawing a trendline between two extreme points and then dividing the vertical distance by the key Fibonacci ratios of: 23.6%, 38.2%, 50%, 61.8%, 78.6%, and 100%.

#hint Price: Price used in the alerts on crossing retracement lines. <b>(Default is Close)</b>
#hint onExpansion: Determines if the retracement lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b>
#hint Extend_to_left: Determines if the retracement lines are extended to the left side of the chart. <b>(Default is No)</b>

#hint Coefficient0: Retracement Line 0: Retracement from the highest high to the lowest low.\n <b>(Default is 0%)</b>
#hint Coefficient_1: Retracement Line 1: Retracement from the highest high to the lowest low.\n <b>(Default is 23.6%)</b>
#hint Coefficient_2: Retracement Line 2: Retracement from the highest high to the lowest low.\n <b>(Default is 38.2%)</b>
#hint Coefficient_3: Retracement Line 3: Retracement from the highest high to the lowest low.\n <b>(Default is 50%)</b>
#hint Coefficient_4: Retracement Line 4: Retracement from the highest high to the lowest low.\n <b>(Default is 61.8%)</b>
#hint Coefficient_5: Retracement Line 5: Retracement from the highest high to the lowest low.\n <b>(Default is 78.6%)</b>
#hint Coefficient_6: Retracement Line 6: Retracement from the highest high to the lowest low.\n <b>(Default is 100%)</b>

#wizard input: Price
#wizard text: Inputs: Price:
#wizard input: onExpansion
#wizard text: onExpansion:
#wizard input: Extend_to_left
#wizard text: Extend_to_left:
#wizard input: Coefficient0
#wizard text: Coefficient0:
#wizard input: Coefficient_1
#wizard text: Coefficient_1:
#wizard input: Coefficient_2
#wizard text: Coefficient_2:
#wizard input: Coefficient_3
#wizard text: Coefficient_3:
#wizard input: Coefficient_4
#wizard text: Coefficient_4:
#wizard input: Coefficient_5
#wizard text: Coefficient_5:
#wizard input: Coefficient_6
#wizard text: Coefficient_6:

input price = close;
input high = high;
input low = low;
input onExpansion = Yes;
input Extend_to_left = no;
input Coefficient0 = 0.000;
input coefficient_1 = .236;
input Coefficient_2 = .382;
input Coefficient_3 = .500;
input Coefficient_4 = .618;
Input Coefficient_5 = .786;
input Coefficient_6 = 1.000;

def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

def upward = highnumberall > lownumberall;
def downward = highnumberall < lownumberall;

def x = AbsValue(lownumberall - highnumberall );

def slope = (a - b) / x;
def slopelow = (b - a) / x;

def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);
def istodaybarnumber = HighestAll(if isToday then barnumber else double.nan);

def line = b + (slope * (barnumber - lownumber));
def linelow = a + (slopelow * (barnumber - highnumber));

def currentlinelow = if barnumber <= lownumberall then linelow else double.nan;
def currentline = if barnumber <= highnumberall then line else double.nan;

def FibFan =  if  downward then currentlinelow else if upward then currentline else double.nan;

def range =  a - b;

def Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan;

def Retracement1 =  if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan;

def Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan;

def Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan;

def Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan;

def Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan;


def Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan;

plot scan = price crosses below retracement4 and retracement5;

#End Code
##########################################################################

Fibonacci Watchlist
------------------------------------------------

#Created by RyanHendricks.
#Modified by #BonBon Feb 2020

#BonBon changed the color of trendlines and added the price to the fibFan percentage
#BonBon updated Feb 2020 created a scan that will look for stocks based on the criteria - price crosses below the 61.8% and 78.6% before gapping up.
#BonBon  updated Feb 2020 to create a watchlist based on the criteria - price crosses below 50%,  61.8% and 78.6% .

#hint: <b>Fibonacci Retracements</b>\nFibonacci retracements use horizontal lines to indicate areas of support or resistance at the key Fibonacci levels before it continues in the original direction. These levels are created by drawing a trendline between two extreme points and then dividing the vertical distance by the key Fibonacci ratios of: 23.6%, 38.2%, 50%, 61.8%, 78.6%, and 100%.


#hint Price: Price used in the alerts on crossing retracement lines. <b>(Default is Close)</b>
#hint onExpansion: Determines if the retracement lines are projected past the current bar into the right side expansion <b>(Default is Yes)</b>
#hint Extend_to_left: Determines if the retracement lines are extended to the left side of the chart. <b>(Default is No)</b>

#hint Coefficient0: Retracement Line 0: Retracement from the highest high to the lowest low.\n <b>(Default is 0%)</b>
#hint Coefficient_1: Retracement Line 1: Retracement from the highest high to the lowest low.\n <b>(Default is 23.6%)</b>
#hint Coefficient_2: Retracement Line 2: Retracement from the highest high to the lowest low.\n <b>(Default is 38.2%)</b>
#hint Coefficient_3: Retracement Line 3: Retracement from the highest high to the lowest low.\n <b>(Default is 50%)</b>
#hint Coefficient_4: Retracement Line 4: Retracement from the highest high to the lowest low.\n <b>(Default is 61.8%)</b>
#hint Coefficient_5: Retracement Line 5: Retracement from the highest high to the lowest low.\n <b>(Default is 78.6%)</b>
#hint Coefficient_6: Retracement Line 6: Retracement from the highest high to the lowest low.\n <b>(Default is 100%)</b>

#wizard input: Price
#wizard text: Inputs: Price:
#wizard input: onExpansion
#wizard text: onExpansion:
#wizard input: Extend_to_left
#wizard text: Extend_to_left:
#wizard input: Coefficient0
#wizard text: Coefficient0:
#wizard input: Coefficient_1
#wizard text: Coefficient_1:
#wizard input: Coefficient_2
#wizard text: Coefficient_2:
#wizard input: Coefficient_3
#wizard text: Coefficient_3:
#wizard input: Coefficient_4
#wizard text: Coefficient_4:
#wizard input: Coefficient_5
#wizard text: Coefficient_5:
#wizard input: Coefficient_6
#wizard text: Coefficient_6:

input price = close;
input high = high;
input low = low;
input onExpansion = Yes;
input Extend_to_left = no;
input Coefficient0 = 0.000;
input coefficient_1 = .236;
input Coefficient_2 = .382;
input Coefficient_3 = .500;
input Coefficient_4 = .618;
Input Coefficient_5 = .786;
input Coefficient_6 = 1.000;

def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

def upward = highnumberall > lownumberall;
def downward = highnumberall < lownumberall;

def x = AbsValue(lownumberall - highnumberall );

def slope = (a - b) / x;
def slopelow = (b - a) / x;

def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);
def istodaybarnumber = HighestAll(if isToday then barnumber else double.nan);

def line = b + (slope * (barnumber - lownumber));
def linelow = a + (slopelow * (barnumber - highnumber));

def currentlinelow = if barnumber <= lownumberall then linelow else double.nan;
def currentline = if barnumber <= highnumberall then line else double.nan;

def FibFan =  if  downward then currentlinelow else if upward then currentline else double.nan;

def range =  a - b;

def Retracement0 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient0))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient0)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient0))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient0)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient0))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient0)) else double.nan;

def Retracement1 =  if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_1)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_1))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_1)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_1))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_1)) else double.nan;

def Retracement2 =if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_2)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_2))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_2)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_2))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_2)) else double.nan;

def Retracement3 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_3)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_3))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_3)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_3))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_3)) else double.nan;

def Retracement4 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_4)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_4))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_4)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_4))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_4)) else double.nan;

def Retracement5 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_5)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_5))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_5)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_5))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_5)) else double.nan;

def Retracement6 = if downward and !onexpansion and !extend_to_left and barnumber >= highnumberall and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and !extend_to_left and !onexpansion and barnumber >= lownumberall and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and !extend_to_left and barnumber >= highnumberall then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and barnumber >= lownumberall and !extend_to_left then highestall(a - (range * coefficient_6)) else if downward and !onexpansion and extend_to_left and barnumber <= istodaybarnumber then highestall((b + (range *  coefficient_6))) else if upward and extend_to_left and !onexpansion and barnumber <= istodaybarnumber then highestall(a - (range * coefficient_6)) else if downward and onexpansion and extend_to_left then highestall((b + (range *  coefficient_6))) else if upward and onexpansion and extend_to_left then highestall(a - (range * coefficient_6)) else double.nan;

def cross3 = price crosses below retracement3;
def cross4 = price crosses below retracement4;
def cross5 = price crosses below retracement5;

def  cross50 = cross3;
def cross618 = cross4;
def cross786 = cross5;

assignbackgroundcolor(if cross50 then color.green else if cross618 then color.magenta else if cross786 then Color.red else color.black);

AddLabel(yes,if cross50 then "50%" else if cross618 then "61.8%" else if cross786 then "78.6%" else "NA", if cross50 then color.black else if cross618  then color.black else if cross786 then color.black else color.white);
 
Last edited:
Here's an interesting refinement to consider.

When I first saw this thread I remembered that I was impressed with a use of TEMA awhile back. Finally I found it again. It was just a single post by @MasterSteve within a thread about an ORB indicator. Here's the specific post about how he uses a TEMA[30] and a EMA[20] on his chart: [ https://usethinkscript.com/threads/opening-range-breakout-indicator-for-thinkorswim.16/post-95 ]. Thanks @MasterSteve !

When used in combination with this Smoothed HA, it looks like it could be powerful. In essence, the strategy could be as follows:

ENTRY LONG (opposite for shorts)
1. Wait for Smoothed HA to change color (let's say bullish).
2. Check TEMA. Is it the bullish color (cyan)?
3. Check the 20 EMA. Is it the bullish color (green)?
4. Is price now closing above just TEMA? Good. Is price closing above both TEMA and the 20EMA? Better.
5. If the top 4 conditions are met, enter long.

SAFETY EXIT
If price retraces but never closes below a bullish TEMA/Bullish EMA it should be safe to stay in the trade. If price closes below the TEMA, this could be considered a safety exit. Re-entry long might be when price closes above the rising TEMA again. However, price closing and remaining below the TEMA (even while still rising) could be a harbinger for a coming trend reversal.

In the image below, you'll see that I've modified the TEMA and EMA to display bullish and bearish colors, which is key. Info about that and links to them are here: [ https://usethinkscript.com/threads/steves-1-000-option-trading-challenge-week-1-update.23/post-41365 ] . I have also included Bollinger Bands on the chart so that I can see the edges of the envelope. Something I like to watch for is when the Smoothed HA changes color after a Bollinger tight squeeze. This could be a good confirmation of trend change and not just a head fake.

Lastly, keep an eye on the TEMA/EMA crosses. While they are often 'late to the party' in terms of entries, they're usually good confirmation for the trade that you've entered.

@RickK - Are you still using this chart and strategy to trader futures?
 
@BonBon Great work :) I added some weighted MA calculations and the chart looks beautiful :) and this is my final version of chart :) See if u like it ... http://tos.mx/TipPyQ2
Thank you @AspaTrader :) I am seeing what you mean, chart is clean and effective. I created a backtest using the TMO code adding this:
plot MainUp = if Main > Signal and Main[1] < os then 1 else 0;
plot MainDown = if Main < Signal and Main[1] > ob and Main < ob then 1 else 0; Makes a pretty reliable trigger. Nice trade on the ES this morning!!(y)
 
Thanks to everyone for their work as I would not have gotten this far without your contribution. I have referenced members of the community as you have either commented or contributed to the HA forums/discussions.

After conducting research on indicators/studies that would aid in my entry and exits as well as keeping me in the trend longer than usual, I came upon Sylvan Vervoort and his work. ( I have previously used the TrendPainter, Supertrend etc.) After reading “Trading with the Heikin-Ashi Candlestick Oscillator" and “Trading Medium-Term Divergences” I began searching the site for script that emulates his work.

@BenTen, @zkm, @mc01439, @HighBredCloud, @JBTrades, @markos, @tomsk @horserider @YungTraderFromMontana @diazlaz @J007RMC

Key components
TEMA, Reversal bubbles and/or arrows, MTF indicator, Addchart script used to create the HA , does not repaint.

Strategy – long and/or short. Enter and/or exit based on reversals (however, I utilize other indicators and signals such as the RSI, MTF, increased volume, stocks with strong catalyst, RV above 2.0 and Fib retracement.

Scan
The scan comprises of the MTF script along with the script for liquidity, relative volume and/or stocks that are near (2-5%) to their 52wk high and short interest. I scan for stocks that are low float.

Watchlist
The watchlist is based on the buy and sell signals.

Feedback from members

I would like feedback from members regarding changing those candles that are “in the trend” but have a different color. (see chart). This would eliminate the number of signals that appear. (especially where there is only one red or green candle in the middle of the current trend. I have tried using strategies such as increasing the lookback period, using the previous candle(s) script but with no success. Please see notes within the chart.

Also, can someone please provide the information for making the Fib lines shorter. Please see notes within the chart.

It is a work in progress. I have made profitable trades and this indicator has allowed me to find setups before major breakouts etc. (this is in combination with the Buy-the Dip).

This is a chart without the regular candles. This shows the HA with the buy and sell signals and the Multi Time Frames. This is the main trading chart. The chart with the candlesticks is used for reference during trading. (I use two monitors when trading)
i7GJm5H.jpg


This is the above chart with the regular candles.
O3grdOi.jpg


This chart shows the Fib Lines and notes on the feedback needed.
ZrGyZKw.jpg


This chart shows the HA candles without the new HA_smoothing chart
3pBHtFX.jpg


This chart shows the scan criteria
DllROT7.jpg


Code
Code:
#Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update Jan 17th 2021
#Influenced by script from HoboTheClown / blt,http://www.thinkscripter.com, TD Hacolt etc.
#MTF based on HannTech's MTF_MACD script
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price

### YOU MUST HAVE THE STYLE SETTING FIT STUDIES ENABLED ###
#hint: The style setting Fit Studies must be enabled to use these bars.


input period = 50;
input hideCandles = yes;
input candleSmoothing = {default Valcu, Vervoort};
input show_bubble_labels = yes;
input bubbles = yes;
input arrows = yes;


#input smoothingLength = 3;

input movingAverageType = {default  TEMA, Exponential, Hull };

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Exponential:
    openMA = CompoundValue(1, ExpAverage(open, period), open);
    closeMA = CompoundValue(1, ExpAverage(close, period), close);
    highMA = CompoundValue(1, ExpAverage(high, period), high);
    lowMA = CompoundValue(1, ExpAverage(low, period), low);

case Hull:
    openMA = CompoundValue(1, HullMovingAvg(open, period), open);
    closeMA = CompoundValue(1,  HullMovingAvg(close, period), close);
    highMA = CompoundValue(1,  HullMovingAvg(high, period), high);
    lowMA = CompoundValue(1,  HullMovingAvg(low, period), low);

case TEMA:
    openMA = CompoundValue(1, TEMA(open, period), open);
    closeMA = CompoundValue(1, TEMA(close, period), close);
    highMA = CompoundValue(1, TEMA(high, period), high);
    lowMA = CompoundValue(1, TEMA(low, period), low);

}


HidePricePlot(hideCandles);

def haOpen;
def haClose;

switch (candleSmoothing){
case Valcu:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);
case Vervoort:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0 ) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);

}

plot o = haOpen;
o.Hide();

def haLow =  Min(lowMA, haOpen);
def haHigh = Max(highMA, haOpen);

#Zero Lag System - MetaStock Crossover Formula
#zero-lagging principle
#Zero-lagging TEMA average on closing prices

#Medium-term price reversals - upward trend

def avg = 34;
def TMA1 = reference TEMA(haClose, avg); # triple exponential moving average (TEMA) of 34 bars
def TMA2 =  reference TEMA(TMA1, avg);
def Diff = TMA1 - TMA2;
def ZlHa = TMA1 + Diff; #Zero-lagging TEMA average on closing prices - medium term uptrend;

#Medium-term price reversals - downward trend
def TMA1_ = reference TEMA((high + low) / 2, avg);
def Diff2 = TMA1_ - TMA2;
def ZlCl = TMA1_ + Diff2; #Zero-lagging TEMA average on closing prices - medium term doenwardtrend;

def ZlDif = ZlCl - ZlHa; # Zero-Lag close - Zero-Lag HA(green candle) Uptrend when ZlDif is equal to or greater than zero

#uptrend {green candle}
def keep1 = if (haClose >= haOpen and haClose[1] >= haOpen[1]) then 1 else 0;
def keep2 = if ZlDif >= 0 then 1 else 0;
def keep3 = if (AbsValue(close - open) < ((high - low) * 0.35)) and high >= low[1] then 1 else 0;
def keeping = if (keep1 or keep2) then 1 else 0;
def keepall = if keeping or (keeping[1]) and close >= open or close >= (close[1]) then 1 else 0;

def utr = if keepall or (keepall[1]) and keep3 then 1 else 0;

#downtrend red candle

def keep1_ = if (haClose < haOpen and haClose[1] < haOpen[1]) then 1 else 0;
def keep2_ = if ZlDif < 0 then 1 else 0;
def keep3_ = if (AbsValue(close - open) < ((high - low) * 0.35)) and low <= high[1] then 1 else 0;
def keeping_ = if (keep1_ or keep2_) then 1 else 0;
def dkeepall_ = if keeping_ or (keeping_[1]) and close < open or close < (close[1]) then 1 else 0;

def dtr = if dkeepall_ or (dkeepall_[1] - 1) and keep3_ == 1 then 1 else 0;  #downtrend
def upw = if dtr and (dtr[1]) and utr then 1 else 0;
def dnw = if !utr and (utr[1] ) and dtr then 1 else 0;

def results = if upw then 1 else if dnw then 0 else results[1];

#Change the color of HA and Japanese Candles - turn off to show only HA on chart
AssignPriceColor(if haClose >= haOpen
                 then Color.GREEN else
                 if  haClose < haOpen
                 then Color.RED else Color.WHITE);


#Heiken_A script

#####################################################################################################
input charttype = ChartType.CANDLE;

def haopen_ = if haClose <= haOpen
              then haOpen + 0
             else Double.NaN;

def HAhi   = if haClose <= haOpen
              then haHigh
              else Double.NaN;

def HAlo =   if haClose <= haOpen
              then haLow
              else Double.NaN;


AddChart(growColor = Color.RED, neutralColor = Color.CURRENT, high = HAhi, low = HAlo, open = haopen_, close = haClose, type = ChartType.CANDLE);

def HAclose1 = ohlc4;
def HAopen1  = if haClose >= haOpen
               then CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (open[1] + close[1]) / 2)  
               else Double.NaN;

def haopen_1 = if haOpen <= haClose
               then HAopen1 + 0  else Double.NaN;

def HAhigh1  = haHigh;
def HAlow1   = haLow;


AddChart(growColor = Color.GREEN, neutralColor = Color.CURRENT,  high = HAhigh1, low = HAlow1, open = haopen_1, close = haClose, type = ChartType.CANDLE);

#####################################################################################################
#Buy and sell signals
def trend =  haClose >= haOpen;
def trendup = trend and !trend[1];
def trendd =  haClose < haOpen;
def trendDown = trendd and !trendd[1];

AddChartBubble(bubbles and trendup and trendup, HAlow1, ("Reversal:"    + round(HAlow1, 2)), Color.GREEN, no);

AddChartBubble(bubbles and trendDown and trendDown, HAhigh1, ("Reversal:"  + round(HAhigh1,2)), Color.LIGHT_RED, yes);

#Arrows instead of bubbles
#def trend = haClose >= haOpen ;
#plot trendup = trend and !trend[1];
#trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#trendup.SetDefaultColor(Color.CYAN);


#def trendd = haClose <= haOpen ;
#plot trendDown = trendd and !trendd[1];
#trendDown.SetDefaultColor(Color.MAGENTA);
#trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

I am looking forward to your feedback. Thanks.
Hey @BonBon.... Thank you for all your help... Is there any way you can share the scan? I cant seem to figure it out... Not a coder... Been trying it for a while...maybe @BenTen can help?
Thank you
 
@BenTen @Ilya @alexR @dominos101 @D_Tramp @Ghs @hexis777 @freedom Traders @JoeSD @AspaTrader @germanburrito @floydddd @rad14733 @barbaros @RickK @guyonabuffalo @Branch @bpVoodoo

Please see below the updates for the chart, the Fibonacci , multi time frame etc. Once again thanks for your input as mentioned previously, my goal was to obtain feedback and support from members.
Part of my strategy is no the first page (#1) and my goal was to have a simple indicator on my trade that allowed for easier entry and exits. During the past months I have been tweaking, revising, abandoning and adopting some of the scripts that I used. At this time I am "satisfied" with my results but I know I will be constantly updating looking for "perfection"

Strategy -Day and Swing Trading
First 5 gappers on scan,( gappers scan, momentum scan, low float scan etc), Low Float – under 100m shares (if a stock has momentum will consider taking the trade if it is favorable), Stocks with a strong catalyst, Market Trend -Uptrend or Downtrend ( I don't short stocks as a rule but will do so depending on the market), utilize fibonacci retracement level (look for gappers to retrace 61.8%)

Entry - Heikin Signals – confirm with volume, catalysts, multiple time frame (main plot must reflect the trend of 3 or more time frames) RSI/Stoch/SVE, market cycle etc.
Exit - Heikin signal - confirm with SVE,Stoch, MTF etc.
Stop loss - just below the Heikin reverse signal, use trailing stop and stop loss.

Now that I have adopted this indicator to be used within my trading plan, I realize my technical and fundamental knowledge helps with assessing risk/rewards even though the Heikin Smoothing trend indicator does a pretty good job of ensuring trades are profitable. After using bollinger bands, TTM Squeeze, moving averages, VWAP, Supertrend, Trendpainter etc. my profit taking is more consistent with this indicator and using the abovementioned confirmations before entering and/or exiting a trade (utilizing alerts on the chart helps as well).

Disclaimer- this is how I use the HA_smoothing indicator within my trading plan. It works for me. Everyone needs to find what works for them. This indicator is not the holy grail but I have found that combined with fundamentals and technicals it can take away some indecisiveness and keep one in the trade longer. On the flip side it can get you out of a trade and decrease the risk.

The first chart shows the updated script with less signals. The signals are based on the swing high swing low script (see below.) As you can see I have been using the new MTF with 6 timeframes. However, only 3 of them are included in the results which are shown in the top plot. When 3 or more of the timeframes are in an bullish/green it is plotted on the top chart. Similarly, the red depicts bearish trend and black neutral.

Additionally, I combined the stochastic and the SVE_Stoc_RSi into one oscillator on the lower chart. This helps identify the 123 wave pullbacks, retracement etc.

AfJEhqT.jpg


This chart shows a longer swing and has less signals. It is based on the zig zag high low script which I adapted. I mostly use this for swing trading but it works great when day trading as well.

kqXvwo7.jpg


This is the 3rd reversal script that can be used. This is another swing high swing low script that I adapted. I have experimented with all of them and based on personal preferences you can make your selection.

LsS27y2.jpg


This chart shows the HA smoothing indicator with the candles. I keep the candles as I prefer seeing the traditional movement. Eventually, having the HA smoothing indicator without the candles will become the norm. Furthermore, I am able to see the set up of the 123 wave during up or downtrends (this is also evident when using the HA smoothing indicator separately).

56Go5Mg.jpg


Here is the chart with the line instead of traditional candles.

kh9tEo2.jpg


This is my watchlist. It consists of the signals, the MTF top line which plots the trend (3 or more in a trend(bullish or bearish)), the relative volume, the SVE,Count (used to confirm the trend reversals) and the price change as of the market open. I also place which stocks can be shorted and those that cannot be shorted on my watchlist..(HTB/ETB). If markets are favorable for shorting I would do so but I seldom short stocks.

p4zCxt2.jpg


The fib lines are still a challenge. I moved the bubbles to the left and incorporated the coefficient and price together as I was not successful in shortening the lines. I am still awaiting members contribution in this area.

vybJ0Sa.jpg


Here is the updated code for the chart. Some of the bubbles and the arrows have been turned off.

Code:
#BonBon - Heiken_Ashi based on Sylvan Verboort's Trading with HA Candlestick Oscillator
#Bon Bon _last update 2/1/2021, Jan 17th 2021,
#Influenced by script from HoboTheClown / blt,http://www.thinkscripter.com, TD Hacolt etc., Thinkscript Cloud, TOS & Thinkscript Collection
#update 1/2/21 - changed the default moving average to TEMA.  Changed the period to 35.
#update changed reversal arrows to reversal bubbles with price
#PLEASE DO NOT REMOVE THE HASHTAGS!!!! ONLY REMOVE THEM IF YOU PLAN ON USING THAT PARTICULAR SIGNAL. THERE ARE 3 DIFFERENT SIGNALS IN THE SCRIPT!!!!! IF YOU REMOVE ALL THE HASHTAGS YOU WILL HAVE NUMEROUS SIGNALS ON YOUR CHART!!!!!!!!!

input averagelength = 34;
input percentamount = .01;
input revAmount = .05;
input atrlength = 4;
input period = 50;
input hideCandles = no;
input show_bubble_labels = yes;
input bubbles = yes;
input arrows = yes;
input PaintBars = yes; #Update to add paintbars
input candleSmoothing = {default Valcu, Vervoort};

input movingAverageType = {default TEMA, Hull, Exponential};

def openMA;
def closeMA;
def highMA;
def lowMA;

switch (movingAverageType) {
case Exponential:
    openMA = CompoundValue(1, ExpAverage(open, period), open);
    closeMA = CompoundValue(1, ExpAverage(close, period), close);
    highMA = CompoundValue(1, ExpAverage(high, period), high);
    lowMA = CompoundValue(1, ExpAverage(low, period), low);
case Hull:
    openMA = CompoundValue(1, HullMovingAvg(open, period), open);
    closeMA = CompoundValue(1,  HullMovingAvg(close, period), close);
    highMA = CompoundValue(1,  HullMovingAvg(high, period), high);
    lowMA = CompoundValue(1,  HullMovingAvg(low, period), low);
case TEMA:
    openMA = CompoundValue(1, TEMA(open, period), open);
    closeMA = CompoundValue(1, TEMA(close, period), close);
    highMA = CompoundValue(1, TEMA(high, period), high);
    lowMA = CompoundValue(1, TEMA(low, period), low);
}

HidePricePlot(hideCandles);

def haOpen;
def haClose;

switch (candleSmoothing){
case Valcu:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);

case Vervoort:
    haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0 ) / 2.0), open);
    haClose = ((((openMA + highMA + lowMA + closeMA) / 4.0) + haOpen + Max(highMA, haOpen) + Min(lowMA, haOpen)) / 4.0);
}

plot o = haOpen ;
o.Hide();

def haLow =  Min(lowMA, haOpen);
def haHigh = Max(highMA, haOpen);
#############################################################################################

#Medium-term price reversals - upward trend

def avg = 34;
def TMA1 = reference TEMA(haClose, avg); # triple exponential moving average (TEMA) of 34 bars
def TMA2 =  reference TEMA(TMA1, avg);
def Diff = TMA1 - TMA2;
def ZlHa = TMA1 + Diff; #Zero-lagging TEMA average on closing prices - medium term uptrend; plot line magenta
#def shortCandle = BodyHeight() < (high - low) * candleSizeFactor; #code taken from HACOLT
#Medium-term price reversals - downward trend
def avg2 = 34;
def TMA1_ = reference TEMA((high + low) / 2, avg2);
def Diff2 = TMA1_ - TMA2;
def ZlCl = TMA1_ + Diff2; #Zero-lagging TEMA average on closing prices - medium term doenwardtrend ....plot line yellow;

def ZlDif = ZlCl - ZlHa; # Zero-Lag close - Zero-Lag HA(green candle) Uptrend when ZlDif is equal to or greater than zero

#AssignPriceColor(if haclose >= haopen
               # then Color.GREEN else
                # if haclose < haopen
                # then Color.RED else color.white);

#####################################################################################################
input charttype = ChartType.CANDLE;

def haopen_ = if haClose <= haOpen
              then haOpen + 0
              else Double.NaN;

def HAhi   = if haClose <= haOpen
              then haHigh
              else Double.NaN;

def HAlo =   if haClose <= haOpen
              then haLow
              else Double.NaN;

AddChart(growColor = Color.RED, neutralColor = Color.CURRENT, high = HAhi, low = HAlo, open = haopen_, close = haClose, type = ChartType.CANDLE);

def HAclose1 = ohlc4;
def HAopen1  = if haClose >= haOpen
               then CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (open[1] + close[1]) / 2)   
               else Double.NaN;

def haopen_1 = if haOpen <= haClose
               then HAopen1 + 0  else Double.NaN;

def HAhigh1  = haHigh;
def HAlow1   = haLow;

AddChart(growColor = Color.GREEN, neutralColor = Color.CURRENT,  high = HAhigh1, low = HAlow1, open = haopen_1, close = haClose, type = ChartType.CANDLE);

#####################################################################################################
def trend = if haclose >= haopen then 1 else 0; # halow1[-50]
#plot trendup =  trend and !trend[1];
#trendup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#trendup.SetDefaultColor(Color.GREEN);
#trendup.SetLineWeight(5);

def Trendd =  if haclose < haopen then 1 else 0;
#plot trendDown = Trendd and !Trendd[1] ;
#trendDown.SetDefaultColor(Color.RED);
#trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#trendDown.SetLineWeight(5);

#AddChartBubble(bubbles and trendup  and trendup , HAlow1, ("R$:"  + Round(HAlow1, 2)), Color.CYAN, no);
#AddChartBubble(bubbles and trendDown and trendDown , HAhi, ("R$:"  + Round(HAhi, 2)), Color.CYAN, yes);
########################################################################
End of HA_Smoothing Script

Signals
Original code by Taz43
#updated by BonBon 1/15/21 inccreased swing_back periods, changed "high and Low to Halow1 and Hahigh1".  Included price labels/bubbles.

def bubbles2 = yes;
input swing_back = 20;
input swing_forward = 34;
input swinglow_back = 20;
input swinglow_forward =34;
input maxbars = 50;
input showlevels = Yes;
def sb = swing_back;
def sf = swing_forward;
def sb2 = swinglow_back;
def sf2 = swinglow_forward;
def na = Double.NaN;

def Offset4 =  8; # high(period = "day")and low(period = "day" ) and close(period = "day" ) * 0.03;
def bubblelocation = bubbles2[offset4];

def lfor2 = Lowest(halow, sf2)[-sf2]; #Remember that a negative number inside the square brackets means "after" this bar. So, the above line is defining "lfor" as being the lowest value of the two bars after this bar.
def lback2 = Lowest(halow, sb2)[1]; #This line of code is defining "lback" as the lowest value of the eight bars before this one.

def swinglow2 = if halow < lfor2 and halow < lback2 then 1 else 0;
#Finally, this line is actually defining what a "swing low" is. It says, if the low of this bar is lower than the two bars after this one AND the low of this bar is also lower than or equal to the lowest of the previous eight bars, then this bar is a swing low. So, what that means is that in order to determine whether a point on the chart is either a swing high or a swing low, it must have eight bars before the bar in question, as well as, two bars after it. Looking at the picture above, it can be seen that point "A" is a "swing high" because it is higher than the 8 bars before it AND it is higher than the 2 bars after it. Likewise, point "C" is a "swing low" because it is lower than the 8 bars before it AND it is lower than the 2 bars after it. (I know it's a line chart, not a bar chart. smiling smiley Just work with me here.)

plot sl = if swinglow2 then halow else na;
#sl.SetPaintingStrategy(PaintingStrategy.POINTS);
sl.SetDefaultColor(Color.WHITE);
sl.SetLineWeight(5);

def hfor = Highest(hahigh, sf)[-sf];
def hback = Highest(hahigh, sb)[1];

def swinghigh2 = if hahigh > hfor  and hahigh > hback then 1 else 0;
plot sh = if swinghigh2 then hahigh else na ;
#sh.SetDefaultColor(Color.orange);
#sh.SetPaintingStrategy(PaintingStrategy.POINTS);
sh.SetLineWeight(5);

plot fh = if swinghigh2 then hahigh else na ;
fh.SetDefaultColor(Color.magenta);
#fh.SetPaintingStrategy(PaintingStrategy.booleaN_ARROW_DOWN);
fh.SetLineWeight(5);

plot fl = if swinglow2 then halo else na;
#fl.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
fl.SetDefaultColor(Color.lime);
fl.SetLineWeight(5);

AddChartBubble(bubbles2 and fl and fl , HAlo, ("$:"  + Round(HAlo, 2)), Color.lime, no);
AddChartBubble(bubbles2 and fh and fh , HAhigh, ("$:"  + Round(HAhigh, 2)), Color.magenta, yes);
#######################################################################
Signals

###Ameritrade Thinkscript
#ZigZagHighLow High Low
#updated by BonBon 1/18/21 inccreased pivot lengths and  periods, changed "high and Low to Halow1 and Hahigh1".  Included price labels/bubbles.

def priceH = HAhigh1;
def priceL = HAlow1;
input atrreversal = 2.0;
def atr_atrreversal = atrreversal;
input tickReversal = 0;

#The minimum percentage of price change for a swing to be detected.
input percentageReversal = 5.0;
#Additional value in dollars that can be added to the minimum price change and  ATR change to increase the distance between swing points.                                  
input absoluteReversal = 0.0;
#The period for ATR calculation.
#input atrLength = 5;
#The factor by which the ATR value is multiplied.
#input atrReversal = 1.5;
#tick reversal- Additional value in ticks that can be added to the minimum price change and ATR change to increase the distance between swing points.
#input tickReversal = 0;

Assert(percentageReversal >= 0, "'percentage reversal' must not be negative: " + percentageReversal);
Assert(absoluteReversal >= 0, "'absolute reversal' must not be negative: " + absoluteReversal);
Assert(atrreversal >= 0, "'atr reversal' must not be negative: " + atrreversal);

Assert(percentageReversal != 0 or absoluteReversal != 0 or atrreversal != 0 or tickReversal != 0, "Either 'percentage reversal' or 'absolute reversal' or 'atr reversal' or 'tick reversal' must not be zero");

#Additional value in dollars that can be added to the minimum price change and  ATR change to increase the distance between swing points.                              
def absReversal;
if (absoluteReversal != 0) {
    absReversal = absoluteReversal;
} else {
    absReversal =  tickReversal * TickSize();
}

def hlPivot;
if (atrreversal != 0) {
    hlPivot = percentageReversal / 300 + WildersAverage(TrueRange(haHigh, haClose, haLow), atrlength) / haClose * atrreversal;
} else {
    hlPivot = percentageReversal / 300;
}
def state = {default init, undefined, uptrend, downtrend};
def maxPriceH;
def minPriceL;
def newMax;
def newMin;
def prevMaxH = GetValue(maxPriceH, 1);
def prevMinL = GetValue(minPriceL, 1);

if GetValue(state, 1) == GetValue(state.init, 0) {
    maxPriceH = priceH;
    minPriceL = priceL;
    newMax = yes;
    newMin = yes;
    state = state.undefined;
} else if GetValue(state, 1) == GetValue(state.undefined, 0) {
    if priceH >= prevMaxH {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = prevMinL;
        newMax = yes;
        newMin = no;
    } else if priceL <= prevMinL {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        minPriceL = priceL;
        newMax = no;
        newMin = yes;
    } else {
        state = state.undefined;
        maxPriceH = prevMaxH;
        minPriceL = prevMinL;
        newMax = no;
        newMin = no;
    }
} else if GetValue(state, 1) == GetValue(state.uptrend, 0) {
    if priceL <= prevMaxH - prevMaxH * hlPivot - absReversal {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        minPriceL = priceL;
        newMax = no;
        newMin = yes;
    } else {
        state = state.uptrend;
        if (priceH >= prevMaxH) {
            maxPriceH = priceH;
            newMax = yes;
        } else {
            maxPriceH = prevMaxH;
            newMax = no;
        }
        minPriceL = prevMinL;
        newMin = no;
    }
} else {
    if priceH >= prevMinL + prevMinL * hlPivot + absReversal {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = prevMinL;
        newMax = yes;
        newMin = no;
    } else {
        state = state.downtrend;
        maxPriceH = prevMaxH;
        newMax = no;
        if (priceL <= prevMinL) {
            minPriceL = priceL;
            newMin = yes;
        } else {
            minPriceL = prevMinL;
            newMin = no;
        }
    }
}

def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(priceH), 0, barNumber));
def newState = GetValue(state, 0) != GetValue(state, 1);
def offset = barCount - barNumber + 1;
def highPoint = state == state.uptrend and priceH == maxPriceH;
def lowPoint = state == state.downtrend and priceL == minPriceL;

plot lastH;
if highPoint and offset > 1 {
    lastH = fold iH = 1 to offset with tH = priceH while !IsNaN(tH) and !GetValue(newState, -iH) do if GetValue(newMax, -iH) or iH == offset - 1 and GetValue(priceH, -iH) == tH then Double.NaN else tH;
} else {
    lastH = Double.NaN;
}

plot lastL;
if lowPoint and offset > 1 {
    lastL = fold iL = 1 to offset with tL = priceL while !IsNaN(tL) and !GetValue(newState, -iL) do if GetValue(newMin, -iL) or iL == offset - 1 and GetValue(priceL, -iL) == tL then Double.NaN else tL;
} else {
    lastL = Double.NaN;
}
#Zig Zag Line
#def HA;
#if barNumber == 1 {
   # HA = fold iF = 1 to offset with tP = Double.NaN while IsNaN(tP) do if GetValue(state, -iF) == #GetValue(state.uptrend, 0) then priceL else if GetValue(state, -iF) == GetValue(state.downtrend, 0) #then priceH else Double.NaN;
#} else if barNumber == barCount {
  #  HA = if highPoint or state == state.downtrend and priceL > minPriceL then priceH else if lowPoint #or state == state.uptrend and priceH < maxPriceH then priceL else Double.NaN;
#} else {
   # HA = if !IsNaN(lastH) then lastH else if !IsNaN(lastL) then lastL else Double.NaN;
#}
#HA.SetDefaultColor(GetColor(1));
#HA.EnableApproximation();

#plots up and down arrows
#lasth.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#lasth.SetDefaultColor(Color.yellow);
#lasth.SetLineWeight(5);

#lastl.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#lastl.SetDefaultColor(Color.yellow);
#lastl.SetLineWeight(5);

#AddChartBubble(bubbles and lastL and lastL, HAlow1, ("$:"  + Round(HAlow1, 2)), Color.YELLOW, no);
#AddChartBubble(bubbles and lastH and lastH, HAhigh1, ("$:"  + Round(HAhigh1, 2)), Color.YELLOW, yes);
####################################################################################
Signals

#Thinkscript cloud - Mobius/Robert Payne
#updated BonBon 1/26/2021 - changed the default settings for the swinglows.  Also changed to incorporate the HA Smoothing charttype settings.

#Here is the script for swing high and swing low. Swing high is marked by red arrow and swing low by green arrow. You can change it to dots by changing boolean_arrow_down to points. You can change the size by changing setlineweight to 2,3,4, or 5. The default setting to determine swing high/low is 3 candles but you can change that in edit properties.

input HA_swinglow = 45;
input HA_swinghigh = 45;

# define and plot the most recent high

def HA_trend = hahigh1 >= Highest(hahigh1[1],HA_swinghigh) and hahigh1 >= Highest(hahigh1[- HA_swinghigh], HA_swinghigh);
def HA_signal1 = if BarNumber() < HA_swinghigh then Double.NaN else if HA_trend then hahigh1 else Double.NaN;
plot HATrend = HA_signal1;
        #HATrend.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
        HATrend.SetDefaultColor(Color.DOWNTICK);
       HATrend.SetLineWeight(5);

# define and plot the most recent low

def HA_trend2 = halow1 <= Lowest(halow1[1],  HA_swinglow) and halow1 <= Lowest(halow1[-  HA_swinglow],  HA_swinglow);
def HA_signal2 = if BarNumber() <  HA_swinglow then Double.NaN else if HA_trend2 then halow1 else Double.NaN;
plot HATrend2 = HA_signal2;
      # HATrend2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
       # HATrend2.SetDefaultColor(Color.UPTICK);
       # HATrend2.SetLineWeight(5);

#AddChartBubble(bubbles and HATrend2 and HATrend2, HAlow1, ("$:"  + Round(HAlow1, 2)), Color.lime, no);
#AddChartBubble(bubbles and HATrend and HATrend, HAhigh1, ("$:"  + Round(HAhigh1, 2)), Color.magenta, yes);

#End code
#################################################

Multi-Time Frame Script for the lower chart

# Multi time-frame Heikin
#BonBon 1/29/21
#  Four hours and Day MTF not included in the top plot. Three or more of the indicators must be green or red to plot.


declare lower;

input UsePeriod5 = AggregationPeriod.FIVE_MIN;
input UsePeriod15 = AggregationPeriod.FIFTEEN_MIN;
input UsePeriod30 = AggregationPeriod.thirty_MIN;
input UsePeriod60 = AggregationPeriod. HOUR;
input UsePeriod4hr = AggregationPeriod. FOUR_HOURS;
input UsePeriodday = AggregationPeriod.DAY;

input  Con_Cri = 3;

input Main_Heikin_Plot = Yes;


#Timeframe1 5 min

def aOpen5 = open(period = UsePeriod5);
def aClose5 = close(period = UsePeriod5);
def aHigh5 = high(period = UsePeriod5);
def aLow5 = low(period = UsePeriod5);

def haClose5 = (aOpen5 + aClose5 + aHigh5 + aLow5) / 4;
def haOpen5 = (haOpen5[1] + haClose5[1]) / 2;

def trend5 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
plot HA_Up5 = if IsNaN(UsePeriod5) then Double.NaN else 6;
HA_Up5.SetPaintingStrategy(PaintingStrategy.POINTS);#SetStyle(curve.Points);
HA_Up5.AssignValueColor(if haClose5 >= haOpen5 then Color.GREEN else if haClose5[1] < haOpen5[1] then Color.RED else Color.CURRENT);
HA_Up5.SetLineWeight(4);
############################################

#Timeframe2 15 mins

def aOpen15 = open(period = UsePeriod15);
def aClose15 = close(period = UsePeriod15);
def aHigh15 = high(period = UsePeriod15);
def aLow15 = low(period = UsePeriod15);

def haClose15 = (aOpen15 + aClose15 + aHigh15 + aLow15) / 4;
def haOpen15 = (haOpen15[1] + haClose15[1]) / 2;


def trend15 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
plot HA_Up15 = if IsNaN(UsePeriod15) then Double.NaN else 5;
#plot HA_Up15 = if haClose15 >= haOpen15 then 1 else 0;
HA_Up15.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up15.AssignValueColor(if haClose15 >= haOpen15 then Color.GREEN else if haClose15 [1]< haOpen15[1] then Color.RED else Color.CURRENT);
HA_Up15.SetLineWeight(4);
#######################################

#Timeframe3  30 mins

def aOpen30 = open(period = UsePeriod30);
def aClose30 = close(period = UsePeriod30);
def aHigh30 = high(period = UsePeriod30);
def aLow30 = low(period = UsePeriod30);

def haClose30 = (aOpen30 + aClose30 + aHigh30 + aLow30) / 4;
def haOpen30 = (haOpen30[1] + haClose30[1]) / 2;


def trend30 = if haClose30 >= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
plot HA_Up30 = if IsNaN(UsePeriod30) then Double.NaN else 4;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up30.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up30.AssignValueColor(if haClose30 >= haOpen30 then Color.GREEN else if haClose30[1] < haOpen30[1] then Color.RED else Color.CURRENT);
HA_Up30.SetLineWeight(4);

################################
#Timeframe4  60mins

def aOpen60 = open(period = UsePeriod60);
def aClose60 = close(period = UsePeriod60);
def aHigh60 = high(period = UsePeriod60);
def aLow60 = low(period = UsePeriod60);

def haClose60 = (aOpen60 + aClose60 + aHigh60 + aLow60) / 4;
def haOpen60 = (haOpen60[1] + haClose60[1]) / 2;

def trend60 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
plot HA_Up60 = if IsNaN(UsePeriod60) then Double.NaN else 3;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up60.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up60.AssignValueColor(if haClose60 >= haOpen60 then Color.GREEN else if haClose60[1] < haOpen60[1] then Color.RED else Color.CURRENT);
HA_Up60.SetLineWeight(4);

##################################
#Timeframe5 4hrs

def aOpen4hr = open(period = UsePeriod4hr);
def aClose4hr = close(period = UsePeriod4hr);
def aHigh4hr = high(period = UsePeriod4hr);
def aLow4hr = low(period = UsePeriod4hr);

def haClose4hr = (aOpen4hr + aClose4hr + aHigh4hr + aLow4hr) / 4;
def haOpen4hr = (haOpen4hr[1] + haClose4hr[1]) / 2;

def trend4hr = if haClose4hr >= haOpen4hr then 1 else if haClose4hr < haOpen4hr then -1 else 0;
plot HA_Up4hr = if IsNaN(UsePeriod4hr) then Double.NaN else 2;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Up4hr.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Up4hr.AssignValueColor(if haClose4hr >= haOpen4hr then Color.GREEN else if haClose4hr[1] < haOpen4hr[1] then Color.RED else Color.CURRENT);
HA_Up4hr.SetLineWeight(4);
#######################################

#Timeframe6 Day

def aOpenday = open(period = UsePeriodday);
def aCloseday = close(period = UsePeriodday);
def aHighday = high(period = UsePeriodday);
def aLowday = low(period = UsePeriodday);

def haCloseday = (aOpenday + aCloseday + aHighday + aLowday) / 4;
def haOpenday = (haOpenday[1] + haCloseday[1]) / 2;

def trendday = if haCloseday >= haOpenday then 1 else if haCloseday [1] < haOpenday[1] then -1 else 0;
plot HA_Upday = if IsNaN(UsePeriodday) then Double.NaN else 1;
#plot HA_Up60 = if haClose60 >= haOpen60 then 1 else 0;
HA_Upday.SetPaintingStrategy(PaintingStrategy.Points);#SetStyle(Curve.POINTS);
HA_Upday.AssignValueColor(if haCloseday >= haOpenday then Color.GREEN else if haCloseday[1] < haOpenday[1] then Color.RED else Color.CURRENT);
HA_Upday.SetLineWeight(4);

####################################
#def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
#def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
#def Trend3 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
#def Trend4 = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
#def Trend5_ = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
#def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
#def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
#def Trend3c = if haClose60 < haOpen60  then 1 else if haClose60[1]>= haOpen60[1] then -1 else 0;
#def Trend4d = if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
#def Trend5e = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#Up Trend
def Trend1 = if haClose5 >= haOpen5 then 1 else if haClose5[1] < haOpen5[1] then -1 else 0;
def Trend2 = if haClose15 >= haOpen15 then 1 else if haClose15[1] < haOpen15[1] then -1 else 0;
def Trend3 = if haClose30>= haOpen30 then 1 else if haClose30[1] < haOpen30[1] then -1 else 0;
def Trend4 = if haClose60 >= haOpen60 then 1 else if haClose60[1] < haOpen60[1] then -1 else 0;
def Trend5_ = if haClose4hr >= haOpen4hr then 1 else if haClose4hr[1] < haOpen4hr[1] then -1 else 0;
def Trend6 = if  haCloseday >= haOpenday then 1 else if haCloseday[1] < haOpenday[1] then -1 else 0;

#Down Trend
def Trend1a = if haClose5 < haOpen5 then 1 else if haClose5[1] >= haOpen5[1] then -1 else 0;
def Trend2b = if haClose15 < haOpen15 then 1 else if haClose15[1] >= haOpen15[1] then -1 else 0;
def Trend3c = if haClose30 < haOpen30 then 1 else if haClose30[1] >= haOpen30[1] then -1 else 0;
def Trend4d = if haClose60 < haOpen60  then 1 else if haClose60[1] >= haOpen60[1] then -1 else 0;
def Trend5e= if haClose4hr < haOpen4hr then 1 else if haClose4hr[1] >= haOpen4hr[1] then -1 else 0;
def Trend6f = if  haCloseday < haOpenday  then 1 else if haCloseday[1] >= haOpenday[1] then -1 else 0;

#plot MTF_TREND = 6;
#MTF_TREND.SetPaintingStrategy(PaintingStrategy.Points);
#MTF_TREND.SetLineWeight(lineWeight = 3);
#MTF_TREND.DefineColor("Buy", GetColor(5));
#MTF_TREND.DefineColor("Sell", GetColor(6));
#MTF_TREND.AssignValueColor(if (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 then Color.GREEN else Color.RED);

#MTF_TREND.AssignValueColor(if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) >= 3 #then Color.GREEN else if PaintBars is false and (Trend1 + Trend2 + Trend3 + Trend4 + Trend5_) < 3 then #Color. RED else Color.CURRENT);

def HA_MTF_TrendUP = (Trend1 + Trend2 + Trend3 + Trend4) >=  Con_Cri ;
def HA_MTF_TrendDN = (Trend1a + Trend2b + Trend3c + Trend4d) >=  Con_Cri;

plot Main_Heikin = 7;
Main_Heikin.SetPaintingStrategy(PaintingStrategy.POINTS);
Main_Heikin.AssignValueColor(if HA_MTF_TrendUP == 1 then Color.Green else if HA_MTF_TrendDN == 1 then color.red else Color.Black);
Main_Heikin.SetLineWeight(4);

#End code
#######################################################
Thank You @BonBon . I really appreciate your effort in putting this together. CAn you help me as how the code be used in TOS? Do I need to paste all the code in the Study indicator or the code need to be broken into parts and used. If handy can you post TOS links for the indicator might be really useful. Thank you again.
 
Hello @BonBon, I love this indicator so far. I have been trying to figure out how to scan for the bubbles. But I am not having much success could somebody help me with this?
 
Thank You @BonBon . I really appreciate your effort in putting this together. CAn you help me as how the code be used in TOS? Do I need to paste all the code in the Study indicator or the code need to be broken into parts and used. If handy can you post TOS links for the indicator might be really useful. Thank you again.
could you share the link to the chart with all indicators please? Thanks for you help.
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
408 Online
Create Post

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