bulldog737
New member
Hey this is an extremely useful indicator but I am trying to scan for the trend reversal and I can't quite figure out how to do so, any help would be much appreciated.
@alexR This is the lower Code...could you share the link to the chart with all indicators please? Thanks for you help.
#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,[URL]http://www.thinkscripter.com[/URL], 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!!!!!!!!!
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
#######################################################
@AspaTrader Could you please share the TMO script/code after you did the backtesting for the trigger please? ThanksThank 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!!
@AspaTrader did not post a backtest, I just used the code in the shared link and added a trigger. It may not be accurate but it was just an attempt to simulate TMO rising from the green zone.@AspaTrader Could you please share the TMO script/code after you did the backtesting for the trigger please? Thanks
# TMO ((T)rue (M)omentum (O)scilator)
# Mobius
# V01.05.2018
input length = 14;
input calcLength = 5;
input smoothLength = 3;
def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > GetValue(o, i)
then 1
else if c < GetValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def ob = if IsNaN(c) then Double.NaN else Round(length * .7);
def os = if IsNaN(c) then Double.NaN else -Round(length * .7);
# code below to determine when Main oscillator ascending from Green zone(os) or descending from red zone(ob)
def MainUp = if Main > Signal and Main[1] < os a then 1 else 0;
def MainDown = if Main < Signal and Main[1] > ob and Main < ob then 1 else 0;
@AspaTrader has shared his setup, based on what he wrote, he uses TMO indicator for a buy signal(if I’m correct).. I am still trying to figure a way to scan for this setup..Can some one share watch list and scan scripts based on the Buy and Sell Signals ?
Thank you
Like that TMO - very nice@AspaTrader
See below the TMO with breakouts. This was in my bag of tricks (came across it last year and modified adding breakouts. I did not need all the code and only kept the TMO script.
https%3A//i.imgur.com/5vgGzc7.jpg[/img]']
https://tos.mx/MwNMpuW
Hi @AspaTrader - Could you please share your chart setup? - I did try using the TOS link you had shared earlier but I only see one line which I believe is the HA.Today's trade ... 3876 to 3894
@AspaTrader. How did you incorporate the cup and handle? I use the built in that was tweaked by Robert Payne. Can you share the script?TTD trade today
@astpatrader I have been tweaking the TOS script to find intraday cup and handle setups. I tend to find them by site but would prefer to have a script that finds them automatically. The TOS script works more for swing trading.@AspaTrader. How did you incorporate the cup and handle? I use the built in that was tweaked by Robert Payne. Can you share the script?
Hi @BonBon - Thanks for sharing this indicator, appreciate it!@astpatrader I have been tweaking the TOS script to find intraday cup and handle setups. I tend to find them by site but would prefer to have a script that finds them automatically. The TOS script works more for swing trading.
@dominos101 I have this issue with my Lower Indicator!!! how do I correct it ? pleaseYeah he's talking about this
@dominos101 I have this issue with my Lower Indicator!!! how do I correct it ? please
@dominos101 check post #220@dominos101 I have this issue with my Lower Indicator!!! how do I correct it ? please
#https://www.hahn-tech.com/ans/alert-setting-on-heikin-ashi-candles/
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose > haOpen;
plot trendUp = haColor and !haColor[1];
trendUp.SetDefaultColor(Color.CYAN);
trendUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot trendDown = !haColor and haColor[1];
trendDown.SetDefaultColor(Color.MAGENTA);
trendDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Alert(trendUp, "Trend Up", Alert.BAR, Sound.RING);
Alert(trendDown, "Trend Down", Alert.BAR, Sound.RING);
#https://www.hahn-tech.com/ans/alert-setting-on-heikin-ashi-candles/
def haClose = ohlc4;
def haOpen = if haOpen[1] == 0 then haClose[1] else (haOpen[1] + haClose[1]) / 2;
def haHigh = Max(high, Max(haClose, haOpen));
def haLow = Min(low, Min(haClose, haOpen));
def haColor = haClose > haOpen;
def trendUp = haColor and !haColor[1];
def trendDown = !haColor and haColor[1];
plot scan = trendUp;
#plot scan = trendDown;
Thank you for the kind words.Thanks...BTW Joo7RMC..I have been reading most of everything posted on this site.. You are the first person I ever posted to. Your post have helped me a ton...
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.