Heiken Ashi Scan

darkelvis

Member
Is it possible to create a scanner for ThinkorSwim that will find green Heikin Ashi candles within the last 2 bars or would that be impossible? Thanks in advance.
 
Last edited by a moderator:
@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?

Which plot did you select... That exact code is working on my system right now... Scanning for long returned no results for my short watchlist due to todays down market, but it returned for unconfirmed and short...

gPrTJ8K.png


gwScI7x.png
 

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

Here 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
How can I use this script to create scan in TOS?
 
How can I use this script to create scan in TOS?

Save the script as a Study, reference the Study from within the Stock Hacker Scanner, select the plot desired, set your timeframe, and scan for results... Earlier in this topic I'm fairly certain I posted a link to another topic where I also explained this... This is a standard method of using scripts in scans... By using this method you don't need to constantly edit a script to comment and uncomment multiple plots to get different results...
 
Last edited by a moderator:
Here 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...

UPDATES:

# 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.

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.
# 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
Apologies as IM new to inputting the thinkscript into TOS. I was able to input the actual Study script and that works great. But when I cut n paste each of your LONG and SHORT and UNCONFIRMED line text for the Scan I'm confused about where to place the line for LONG and then in a separate but similar scan where to insert the line for SHORT ...and ...which existing line should be deleted from the script you have above. Thanks in advance
 
@JOMO59 The simplest way to use the Scan Study is to goto the Stock Hacker Scanner, delete all existing filters, click Add Filter, select Study, click on the pencil icon to edit, Delete the existing condition, click on Add Condition, in the Select a condition dropdown select Study, locate your Study name (Heikin_Ashi_Trend_Dots_Scan), select the plot you want to use (long, short, unconfirmed), select is true, click on Save, at the top of the Scanner Custom Filter panel select your desired Aggregation Period, click Ok at the bottom of the panel, make sure you have chosen the proper Scan in selection for your needs, and you are now ready to click Scan or to add any additional filters you may desire... You can then save this scan for future use and optionally set the scan to send Alerts... Repeat the process for any of the other plots you desire to run... You can't break anything by experimenting... Good luck...
 
The only Plot I get in the drop-down is "haDot" in the scan tab referencing the study. What am I missing. The study was cut and pasted....?

You have the wrong code... Check Post #8 for the Scan code... The only plots in the code are long, short, and unconfirmed... I understand the possibility for confusion... I have been trying to get caught up so I can split this single topic into individual topics for each script...
 
Last edited by a moderator:
You have the wrong code... Check Post #8 for the Scan code... The only plots in the code are long, short, and unconfirmed... I understand the possibility for confusion... I have been trying to get caught up so I can split this single topic into individual topics for each script...
I was just referencing post #37 and attempting to do it that way..... Went Back to #8 and got it loaded correctly. Thanks
 
Last edited:
@rad14733
I noted that after a long red period it transitions yellow then green, helps isolate significant trend changes
# Added to detect significant trend change
def UpTrend = if haSignal[5] == -1 and haSignal[4] == -1 and haSignal[3] == -1 and haSignal[2] == -1 and ( haSignal[1] != -1 and haSignal[1] != 1) and haSignal[0] == 1 then 1 else 0;
AddVerticalLine(UpTrend,"Bull",Color.Green);
 
Yes it was added to lower indicator. I was thinking about a loop, fold statement that you could input the number of down signals to calculate the reversal of the trend. So seeing let say 10 down signals and then start turning up which usually means a stronger up trend. Not just looking at down signals but lower and lower down signals. down and lower closes.
 
Yes it was added to lower indicator. I was thinking about a loop, fold statement that you could input the number of down signals to calculate the reversal of the trend. So seeing let say 10 down signals and then start turning up which usually means a stronger up trend. Not just looking at down signals but lower and lower down signals. down and lower closes.

Your concept might be best suited for a Scan, Custom Watchlist Column, and/or Chart label...
 
Last edited:
Hello!
Trying to see if it is possible to create a scanner with the following parameters:

Chart Type Heikin Ashi, daily
MACD parameters: 20,26,9
Chart colors: Green up, red down

Two Types of scans:
BUY
SELL

BUY parameters:
First green bar after a red bar AND MACD line crossing over the signal line (both conditions have to match)
Return results for any tickets that match the above criteria within the last 3 bars

SELL parameters
First red bar after a green bar AND MACD line crossing BELOW the signal line (both conditions have to match)
Return results for any tickets that match the above criteria within the last 3 bars

I looked at the following thread but was not able to create what I'm looking for.
https://usethinkscript.com/threads/heiken-ashi-scan.7501/page-2#post-74073
 
Hello!
Trying to see if it is possible to create a scanner with the following parameters:

Chart Type Heikin Ashi, daily
MACD parameters: 20,26,9
Chart colors: Green up, red down

Two Types of scans:
BUY
SELL

BUY parameters:
First green bar after a red bar AND MACD line crossing over the signal line (both conditions have to match)
Return results for any tickets that match the above criteria within the last 3 bars

SELL parameters
First red bar after a green bar AND MACD line crossing BELOW the signal line (both conditions have to match)
Return results for any tickets that match the above criteria within the last 3 bars

I looked at the following thread but was not able to create what I'm looking for.
https://usethinkscript.com/threads/heiken-ashi-scan.7501/page-2#post-74073
The Heiken-ashi scan is in post#8
and the ToS indicator is MACD
 
Last edited:
Just looking for an inside bar scanner for heiken ashi candles. There's a plethora of inside bar scanners and the TOS built in scanners would do even I just need to know how to convert that to find them for HA candles instead. Thanks for any help in advance.
 
Just looking for an inside bar scanner for heiken ashi candles. There's a plethora of inside bar scanners and the TOS built in scanners would do even I just need to know how to convert that to find them for HA candles instead. Thanks for any help in advance.
That pattern is not appropriate for use with HA candles
 
@rad14733
I noted that after a long red period it transitions yellow then green, helps isolate significant trend changes
# Added to detect significant trend change
def UpTrend = if haSignal[5] == -1 and haSignal[4] == -1 and haSignal[3] == -1 and haSignal[2] == -1 and ( haSignal[1] != -1 and haSignal[1] != 1) and haSignal[0] == 1 then 1 else 0;
AddVerticalLine(UpTrend,"Bull",Color.Green);
have you able to convert this to scanner?
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
384 Online
Create Post

Similar threads

Similar threads

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