# Heikin Ashi 5 Bar Bearish Trend Change _JQ
# v01 dated 9.23.2018
# Scans for a 5 Bar change in the Heikin Ashi Trend to Bull from Bear
# relies on RHouser HA candle description code
def xClose = ( open + high + low + close ) / 4;
rec xOpen = compoundValue( 1, ( xOpen[1] + xClose[1] ) / 2, xClose );
def Bullish = if ( xClose - xOpen ) >= 0 then yes else no;
def Bearish = if ( xClose - xOpen ) <= 0 then yes else no;
def BullishChange = if ( xClose - xOpen ) >= 0 and ( xClose[1] - xOpen[1] ) <= 0 then yes else no;
def BearishChange = if ( xClose - xOpen ) <= 0 and ( xClose[1] - xOpen[1] ) >= 0 then yes else no;
def BullishChange2Bar = if ( xClose - xOpen ) >= 0 and ( xClose[1] - xOpen[1] ) >= 0 and ( xClose[2] - xOpen[2] ) <= 0 then yes else no;
def BearishChange2Bar = if ( xClose - xOpen ) <= 0 and ( xClose[1] - xOpen[1] ) <= 0 and ( xClose[2] - xOpen[2] ) >= 0 then yes else no;
def BullishChange5Bar = if ( xClose - xOpen ) >= 0
and ( xClose[1] - xOpen[1] ) >= 0
and ( xClose[2] - xOpen[2] ) >= 0
and ( xClose[3] - xOpen[3] ) >= 0
and ( xClose[4] - xOpen[4] ) >= 0
and ( xClose[5] - xOpen[5] ) <= 0
then yes else no;
def BearishChange5Bar = if ( xClose - xOpen ) <= 0
and ( xClose[1] - xOpen[1] ) <= 0
and ( xClose[2] - xOpen[2] ) <= 0
and ( xClose[3] - xOpen[3] ) <= 0
and ( xClose[4] - xOpen[4] ) <= 0
and ( xClose[5] - xOpen[5] ) >= 0
then yes else no;
## Plot Section. Choose one plot only
#plot Scan = Bullish;
#plot Scan = Bearish;
#plot Scan = BullishChange;
#plot Scan = BearishChange;
#plot Scan = BullishChange2Bar;
#plot Scan = BearishChange2Bar;
plot Scan = BullishChange5Bar;
#plot Scan = BearishChange5Bar;
# Heikin Ashi Bullish/Bearish Trend Change _JQ
# v01 dated 9.23.2018
# Scans for a change in the Heikin Ashi Trend to Bull from Bear
# relies on RHouser HA candle description code
def xClose = ( open + high + low + close ) / 4;
rec xOpen = compoundValue( 1, ( xOpen[1] + xClose[1] ) / 2, xClose );
def Bullish = if ( xClose - xOpen ) >= 0 then yes else no;
def Bearish = if ( xClose - xOpen ) <= 0 then yes else no;
def BullishChange = if ( xClose - xOpen ) >= 0 and ( xClose[1] - xOpen[1] ) <= 0 then yes else no;
def BearishChange = if ( xClose - xOpen ) <= 0 and ( xClose[1] - xOpen[1] ) >= 0 then yes else no;
#plot Scan = Bullish;
#plot Scan = Bearish;
plot Scan = BullishChange;
#plot Scan = BearishChange;
######### scan ###################
rec HAopen = compoundValue(1, (HAopen[1] + ohlc4) / 2, ohlc4);
def HAclose = (HAopen + Max(high, HAopen) + Min(low, HAopen) + ohlc4) / 4;
def Bullish = if ( HAclose - HAopen ) >= 0 then yes else no;
plot Scan = Bullish;
########### EOC ############
# Heikin_Ashi_Trend_Dots
# Sounds alerts on trend reversal while eliminating most false signals.
# Paints Yellow dots to signal potential trend reversals while Green and Red dots indicate trend direction.
# Created by rad14733 for usethinkscript.com
# v1.0 : 2021-08-12 : Initial release
# v1.1 : 2021-08-12 : Added option to color Heikin Ashi candles the same as the trend dots.
declare lower;
input useAlerts = yes;
input alertType = Alert.BAR;
input buySound = Sound.DING;
input sellSound = Sound.DING;
input colorBars = yes;
def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def haTrendUp = if haClose >= haOpen then 1 else 0;
def haTrendDn = if haClose < haOpen then 1 else 0;
def haSignal =
if haTrendUp == 1 and haTrendUp[1] == 1 then 1
else if haTrendDn == 1 and haTrendDn[1] == 1 then -1
else 0
;
plot haDot = if !IsNan(haClose) then 0 else Double.NaN;
haDot.DefineColor("UpTrend", Color.GREEN);
haDot.DefineColor("DnTrend", Color.RED);
haDot.DefineColor("Transition", Color.YELLOW);
haDot.SetPaintingStrategy(PaintingStrategy.POINTS);
haDot.SetLineWeight(5);
haDot.AssignValueColor(
if haSignal == 1 then haDot.Color("UpTrend")
else if haSignal == -1 then haDot.Color("DnTrend")
else haDot.Color("Transition")
);
Alert(useAlerts and haSignal[1] == 0 and haSignal == 1, "HA Buy Signal", alertType, buySound);
Alert(useAlerts and haSignal[1] == 0 and haSignal == -1, "HA Sell Signal", alertType, sellSound);
AssignPriceColor(if colorBars then
if haSignal == 1 then haDot.Color("UpTrend")
else if haSignal == -1 then haDot.Color("DnTrend")
else haDot.Color("Transition")
else Color.CURRENT
);
# END - Heikin_Ashi_Trend_Dots
# Heikin_Ashi_Trend_Dots_Scan
# Finds potential trend reversals based on Heikin Ashi trend transition direction.
# Created by rad14733 for usethinkscript.com
# v1.0 : 2021-08-13 : Initial release.
# v1.1 : 2021-08-17 : Added ability to scan for "unconfirmed" (Yellow) signals.
# v1.2 : 2021-08-25 : Fixed logic for proper scan results and added more usage comments.
def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def haTrendUp = if haClose >= haOpen then 1 else 0;
def haTrendDn = if haClose < haOpen then 1 else 0;
def haSignal =
if haTrendUp == 1 and haTrendUp[1] == 1 then 1
else if haTrendDn == 1 and haTrendDn[1] == 1 then -1
else 0
;
# NOTE: ONLY ONE PLOT ALLOWED PER SCAN.
# When Pasting into the TOS Scanners you must comment out the unwanted plots and Un-Comment the desired plot.
# When referencing the Study from within the TOS Scanners, simply select the desired plot.
# Long trend transition (GREEN)
plot long = haSignal == 1;
# Short trend transition (RED)
plot short = haSignal == -1;
# Unconfirmed trend transition (YELLOW)
plot unconfirmed = haSignal == 0;
# END - Heikin_Ashi_Trend_Dots_Scan
If I am understanding this right then the dots indicator change to yellow for 1st color change from green to red or vice versa and confirmation to that color happens with second Heikin Ashi candle of same color. Is this understanding correct?
@rad14733 Is there a way I can get the scan to pull up the stocks when the indicator is on the first yellow dot? This is the exact strategy I'm practicing on paper right now. Can't thank you enough!
# Heikin_Ashi_Trend_Dashboard
# Paints Yellow bar to signal potential trend reversals while Green and Red bars indicate trend direction.
# Optionally sounds alerts on trend reversal while eliminating most false signals.
# Optionally paints candles based on HA trend
# Created by rad14733 for usethinkscript.com
# v1.0 : 2021-08-17 : Initial release
# v1.1 : 2021-08-18 : Modified to 10 bars from 5
# v1.2 : 2021-08-27 : Added option to hide Dashboard
input useAlerts = no;
input alertType = Alert.BAR;
input buySound = Sound.DING;
input sellSound = Sound.BELL;
input colorBars = no;
input hideDashboard = no;
def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def haTrendUp = if haClose >= haOpen then 1 else 0;
def haTrendDn = if haClose < haOpen then 1 else 0;
def haSignal =
if haTrendUp == 1 and haTrendUp[1] == 1 then 1
else if haTrendDn == 1 and haTrendDn[1] == 1 then -1
else 0
;
DefineGlobalColor("Label", Color.ORANGE);
DefineGlobalColor("UpTrend", Color.GREEN);
DefineGlobalColor("DnTrend", Color.RED);
DefineGlobalColor("Transition", Color.YELLOW);
AddLabel(!hideDashboard, "HA Trend:", GlobalColor("Label"));
AddLabel(!hideDashboard, " ",
if haSignal[9] == 1 then GlobalColor("UpTrend")
else if haSignal[9] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[8] == 1 then GlobalColor("UpTrend")
else if haSignal[8] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[7] == 1 then GlobalColor("UpTrend")
else if haSignal[7] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[6] == 1 then GlobalColor("UpTrend")
else if haSignal[6] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[5] == 1 then GlobalColor("UpTrend")
else if haSignal[5] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[4] == 1 then GlobalColor("UpTrend")
else if haSignal[4] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[3] == 1 then GlobalColor("UpTrend")
else if haSignal[3] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[2] == 1 then GlobalColor("UpTrend")
else if haSignal[2] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal[1] == 1 then GlobalColor("UpTrend")
else if haSignal[1] == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
AddLabel(!hideDashboard, " ",
if haSignal == 1 then GlobalColor("UpTrend")
else if haSignal == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
);
Alert(useAlerts and haSignal[1] == 0 and haSignal == 1, "HA Buy Signal", alertType, buySound);
Alert(useAlerts and haSignal[1] == 0 and haSignal == -1, "HA Sell Signal", alertType, sellSound);
AssignPriceColor(if colorBars then
if haSignal == 1 then GlobalColor("UpTrend")
else if haSignal == -1 then GlobalColor("DnTrend")
else GlobalColor("Transition")
else Color.CURRENT
);
# END - Heikin_Ashi_Trend_Dashboard
Hi, How do I exactly set this scan up in TOS--thanksHere is the scan code for this indicator... I recommend saving two separate scans, one for Longs and one for Shorts... I have tested against my main Watchlist using various timeframes with successful results... Enjoy...
Ruby:# Heikin_Ashi_Trend_Dots_Scan # Finds potential trend reversals based on Heikin Ashi trend transition direction. # Created by rad14733 for usethinkscript.com # v1.0 : 2021-08-13 : Initial release # v1.1 " 2021-08-17 : Added ability to scan for "unconfirmed" (Yellow) signals def haClose = ohlc4; def haOpen = (haOpen[1] + haClose[1]) / 2; def haTrendUp = if haClose >= haOpen then 1 else 0; def haTrendDn = if haClose < haOpen then 1 else 0; def haSignal = if haTrendUp == 1 and haTrendUp[1] == 1 then 1 else if haTrendDn == 1 and haTrendDn[1] == 1 then -1 else 0 ; # NOTE: ONLY ONE PLOT ALLOWED PER SCAN. # Comment out the unwanted plots and Un-Comment the desired plot # Long trend transition plot long = haSignal[1] == 0 and haSignal == 1; # Short trend transition plot short = haSignal[1] == 0 and haSignal == -1; # Unconfirmed trend transition plot unconfirmed = if (haTrendUp == 1 and haTrendUp[1] == 0) or (haTrendDn == 1 and haTrendDn[1] == 0) and haSignal != haSignal[1] then 1 else Double.NaN; # END - Heikin_Ashi_Trend_Dots_Scan
After playing around, I did get something to work.. The column shows the color of the dot - but just shows 0.0 instead of the dot. I can make due with it! The code I tinkered with/used is:Hi rad14733 amazing indicator! I have a quick question for you, and hope it's something that's quite easy (I just have no idea where to start). Is there a way to show the current day's dot color in a watch list? For example, as I go through my watchlist, I note all the days that end with a yellow dot. I want to throw those in a watchlist, and be able to see what color the dot is when the market opens the next day. Is that something easily scripted?
declare lower;
def haClose = ohlc4;
def haOpen = (haOpen[1] + haClose[1]) / 2;
def haTrendUp = if haClose >= haOpen then 1 else 0;
def haTrendDn = if haClose < haOpen then 1 else 0;
def haSignal =
if haTrendUp == 1 and haTrendUp[1] == 1 then 1
else if haTrendDn == 1 and haTrendDn[1] == 1 then -1
else 0
;
plot haDot = if !IsNan(haClose) then 0 else Double.NaN;
haDot.DefineColor("UpTrend", Color.GREEN);
haDot.DefineColor("DnTrend", Color.RED);
haDot.DefineColor("Transition", Color.YELLOW);
haDot.SetPaintingStrategy(PaintingStrategy.POINTS);
haDot.SetLineWeight(5);
haDot.AssignValueColor(
if haSignal == 1 then haDot.Color("UpTrend")
else if haSignal == -1 then haDot.Color("DnTrend")
else haDot.Color("Transition")
);
# END - Heikin_Ashi_Trend_Dots
Hi, How do I exactly set this scan up in TOS--thanks
@rad14733 For some reason the update isn't pulling up anything for me. I saved it as a study then created a new scan using the study as usual but nothing comes up. Maybe I'm doing something wrong?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
J | Lower Chart Heiken Ashi With Candles | Questions | 1 | |
E | Heiken Ashi Overlay Displaced | Questions | 1 | |
I | MTF Dashboard Heiken Ashi Labels | Questions | 0 | |
Heiken Ashi Upper Indicator | Questions | 4 | ||
B | Heiken Ashi signal change | Questions | 0 |
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.