Heiken-Ashi Moving Average (HAMA) for ThinkorSwim

MBF

Active member
2019 Donor
I'm looking for the HAMA Heiken Ashi indicator for ThinkorSwim. Can anyone help me find it?
 
@MBF Here is a Heiken Ashi Moving Average study you may like to check out.

Feel free to edit the length of the moving average to suit your requirements:

Code:
# START
def length = 8;
def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close) / 2);
HAhigh = Max(high, close[1]);
HAlow = Min(low, close[1]);
HAclose = (HAopen + HAclose[1] + HAlow + close) / 4;
AssignPriceColor(if HAclose > HAopen then Color.GREEN else color.RED);
plot HAMA = Average(HAclose, length);
# END
 
Last edited:
Heikin Ashi concept is very interesting . In essence its 2 period smoothing of price action, which visually represents what actually happens in trend better than individual candles. However it can be misleading when used in some timeframes. Back to your question. There is this study I made while playing with HKA - it color candles pink when there is HKA trend transition. It can be used both on regular and HKA charts

Code:
#HK
#Use bar to figure trendDown or confirm.
#heikin ashi bars. close=OHLC/4.  open=1/2(open[1]+close[1])  and HA trend
#
def haclose = (open + high + low + close) / 4;
def haopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2);
def hahigh=max(open,max(close,high));def halow=min(open,min(close,high));

def HAtrendUP  = haclose > haclose[1];
def upBar = if HAtrendUP then upBar[1] + 1 else 0;
def HATrendDown = haclose <= haclose[1];
def downBar = if HATrendDown then downBar[1] + 1 else 0;
def bars = upBar + downBar;
#the one with body small relative to wicks . let say less than 0.3
def HAtransition=absvalue((haopen-haclose)/(hahigh-halow))<0.3;
def HARed = HAOpen > HAclose;
def HAGreen = !HARed;
def HADecidedRed = HARed and HAHigh == HAopen;
def HADecidedGreen = HAGreen and HAlow == HAOpen;

plot data=0;
#
AssignPriceColor( if hatransition then color.MAGENTA
    else Color.CURRENT);
 
Yeah it looks good . Like every trending chart does : ) . The issue with trends is that its not hard to identify and paint them postfactum with all the nice entries. I wrote dozens of indicators which do that with 99% accuracy on trending stocks (without repainting). Key is how to get something which will NOT show the signals on things which do not result in trends. Most losses comes from the chop. So indicators which shows trends with 100% accuracy is pretty worthless when it also shows non-trends often. As most price movement is chop odds of getting into chop are very high to start with

p.s. I am now of opinion that inidcator based on the single timeframe can never do that. In fact probably no indicator can do that with high probability if its single timeframe, price action based only. There are other factors which determine that.
 
I really get that but, say you were to apply the RVOL condition? Knowing that a stock will trend one way the other might be helpful in at least picking stocks for the day that have a higher probability to trend.
 
Since you mentioned SMB capital ( I watched their videos a lot) - its what they call "stocks in play". Stocks with catalyst, and rvol etc. One problem with RVOL in TOS - it doesn't have one. You need something which will show relative volume AT TIME OF DAY compared to average volume done at this time of day. And yeah playing stock in play increased the odds of "something" happening. However what actually happens - it might be varied chop and then trend. it might be trend which is gone and done by 945 and then chop. It might be both way fakeouts and then sqz sideways. Many things. So you would narrow down to "something happening" (maybe!) but still problem of knowing when trend starts and not of various fakeouts/chops remains.

I been doing stocks in play for a while now - its far from easy! (at least for me)
 
@skynetgen Right now that is about all I can play. I have been trying to find a decent RVOL on TOS. I just don't get how they have all these complicated scripts or cool scripts but can't find a decent RVOL. THAT is my most complicated area right now is finding stocks to play. I need high IV or at least a very liquid stock that trades $60 and below ATM. Drives me nuts!
 
To find stocks in play I use simply premarket gapper approach . Filtering by price, capitalization and average volume per day (to weed out penny and/ or illiquid stocks). Out of average 15-30 names which pop on scanners 2-4 stocks I pick have at least one mover "stock in play". That is done premarket so I don't have to scramble with scans intraday

Here is this very simple scan: https://tos.mx/WXUxaCb

Another proxy for stocks in play I use is sizzle index. (>2 is wide critera, >5 picks something with big catalyst practically every day)
 
Thank you @skynetgen! I don't really understand that last part, (>2 is wide critera, >5 picks something with big catalyst practically every day).
 
If you add stocks to your watchlist and add sizzle index column just sort by it . - indicates increased activity - basically a proxy to relvol (very often you will see significantly increased volume on those stocks).

There is small bug here (uses close instead of haclose). Anyhow this HA code works better than one I was using before. Integrated it with my transition code https://tos.mx/aA77lzO
 
  • Love
Reactions: MBF
Here is the revised code:

Code:
def length = 8;
def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close) / 2);
HAhigh = Max(high, close[1]);
HAlow = Min(low, close[1]);
HAclose = (HAopen + HAclose[1] + HAlow + close) / 4;
AssignPriceColor(if HAclose > HAopen then Color.GREEN else color.RED);
plot HAMA = Average(HAclose, length);
 
This is a comparison I did using the HA_MA 10 with the VWMA 10. The green line is the HA_MA and the cyan/brn line is the VWMA

RrvvZ9z.png

RrvvZ9z.png
 

Attachments

  • RrvvZ9z.png
    RrvvZ9z.png
    154.9 KB · Views: 385
  • RrvvZ9z.png
    RrvvZ9z.png
    154.9 KB · Views: 454
following this...From my testing thus far of various SuperTrends...its hard to beat good ole Heikin Ashi...What I am wondering about tho is if anyone was able to make a SuperTrend based on Heikin Ashi but to use regular candles? I have seen many that overlap regular candles with Heikin Ashi candles...but that's not the same as Heikin Ashi trend on regular candles...
 
@HighBredCloud Per your request here's a version of SuperTrend using Heiken Ashi from Mobius. Please enjoy this!

Code:
# Mobius
# SuperTrend HeikenAshi
# V03.10.2015
# Up = (HIGH + LOW) / 2 + Multiplier * ATR
# Down = (HIGH + LOW) / 2 – Multiplier * ATR
# When the change of trend occurs, the indicator flips

input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
input BubbleOn = no;
input ShowLabel = no;
input AlertOn = no;
input PlotLine = no;

def HAopen;
def HAhigh;
def HAlow;
def HAclose;
HAopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close) / 2);
HAhigh = Max(high, close[1]);
HAlow = Min(low, close[1]);
haclose = (HAopen + HAclose[1] + HAlow + close) / 4;
def v = volume;
def bar = barNumber();
def EOD = if SecondsTillTime(1545) == 0 and
             SecondsFromTime(1545) == 0
          then 1
          else 0;
def NotActive = if SecondsFromTime(1545) > 0
                then 1
                else 0;
def ATR = MovingAverage(AvgType, TrueRange(HAhigh, HAclose, HAlow), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1]
         then Round(UP / tickSize(), 0) * tickSize()
         else Round(DN / tickSize(), 0) * tickSize();
plot SuperTrend = ST;
SuperTrend.SetHiding(!PlotLine);
SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
SuperTrend.SetPaintingStrategy(PaintingStrategy.Line);
AssignPriceColor(if PaintBars and close < ST
                 then Color.RED
                 else if PaintBars and close > ST
                      then Color.GREEN
                      else Color.CURRENT);
plot ST_point = if isNaN(close[-1])
                then ST
                else double.nan;
ST_point.SetStyle(Curve.Points);
ST_point.SetLineWeight(3);
ST_point.SetDefaultColor(Color.Yellow);
# End Code SuperTrend HeikenAshi
 
Would someone be able to help code a strategy based on HAMA? I think it could be a useful strategy to buy on the first green candle that closes and then reverse the position on the first red candle that closes. The only challenge i foresee is that since the study is hiding the underlying renko bricks and generating HAMA candles, I'm not sure if TOS can generate buy sell signals based on the candles that the indicator is producing. I am running this indicator on a 2 tick renko and it looks to be producing favorable results.

Here is the indicator. Hope someone can help. Thanks in advance.

https://tos.mx/pLITkME
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
355 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