Heikin_Ashi Indicator For ThinkOrSwim

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

@BonBon Hi bro, please, where I can find codes: MTF_15, MTF_60, MTF_240 and MTF_Day?

a06YbsQ.jpg
@BonBon and Hexis777 --- Can someone repost the completed "working" code for this MTF? I have been going down the rabbit hole trying to follow this thread.
 
Thanks once to everyone who contributed to the discussion. Finally, I have been successful in eliminating the numerous signals keeping the lowest and the highest reversal signals. I am cleaning up the script and will post the final results.

hi, bonbon: any updates for us? just checking!
 
@RickK Are you trading /ES live using this strategy?

/ES, NQ and /RTY. But, like @BonBon I am struggling a bit with exits (and chop). As everyone is, I'm looking for an instrument that has more steady movement and fewer indiscriminate surges in the opposite direction. I'm looking forward to her next post.

Also, I've been testing with different settings. Using fibonacci numbers as a guide (I learned this somewhere), I've been trying to set the indicator and the accompanying TEMA line to different values. Started with 34, then to 21 and even 13 to see if it would help with fast scalping. I haven't concluded anything yet.

Consider the image below.
 
Last edited:
  • Like
Reactions: Ghs
Never mind, I see it in TOS. I thought it was embedded in the code..
I am new to this method, have been following it and getting good results.
Than You for your response.-
 
Hey @BonBon , I don't see that anyone has responded with any ideas for combining the MTF indicators (as you noted in post #1), but I'll take a stab at it. Do you still, in fact, use them on your charts?

Anyway, although I don't really know how it's done, here's a study that combines a number of separate indicators into a single heat map (dots) style display. Maybe you'll gather some ideas about how to address your dilemma.

Code:
#Custom Trend Multi Indicator Heat Map by 7of9

declare lower;

input CloseVsSmaTrendLength = 8;
input VolumeBarSensitivity = 3;
input VWapTimeFrame = {default DAY, WEEK};

#Dot Placement Code

def DotOffset1 = 1;
def DotOffset2 = 2;
def DotOffset3 = 3;
def DotOffset4 = 4;
def DotOffset5 = 5;
def DotOffset6 = 6;
def DotOffset7 = 7;
def DotOffset8 = 8;
def DotOffset9 = 9;
def DotOffset10 = 10;
def DotOffset11 = 11;
def DotOffset12 = 12;

#EMA Code

def AvgExp9 = ExpAverage(close, 9);
def AvgExp20 = ExpAverage(close, 20);
def AvgExp50 = ExpAverage(close, 50);
def AvgExp100 = ExpAverage(close, 100);
def AvgExp200 = ExpAverage(close, 200);

#EMA Trend Code

plot Up50 = if AvgExp50 > AvgExp50[1] then DotOffset1 else Double.NaN;
plot Dn50 = if AvgExp50 < AvgExp50[1] then DotOffset1 else Double.NaN;

Up50.SetDefaultColor(Color.GREEN);
Up50.SetStyle(Curve.POINTS);
Up50.SetLineWeight(1);

Dn50.SetDefaultColor(Color.RED);
Dn50.SetStyle(Curve.POINTS);
Dn50.SetLineWeight(1);

#EMA Crossover Code

plot Up9x20 = if AvgExp9 > AvgExp20 then DotOffset2 else Double.NaN;
plot Up9x50 = if AvgExp9 > AvgExp50 then DotOffset3 else Double.NaN;
plot Up9x100 = if AvgExp9 > AvgExp100 then DotOffset4 else Double.NaN;
plot Up9x200 = if AvgExp9 > AvgExp200 then DotOffset5 else Double.NaN;

plot Dn9x20 = if AvgExp9 < AvgExp20 then DotOffset2 else Double.NaN;
plot Dn9x50 = if AvgExp9 < AvgExp50 then DotOffset3 else Double.NaN;
plot Dn9x100 = if AvgExp9 < AvgExp100 then DotOffset4 else Double.NaN;
plot Dn9x200 = if AvgExp9 < AvgExp200 then DotOffset5 else Double.NaN;

Up9x20.SetDefaultColor(Color.GREEN);
Up9x20.SetStyle(Curve.POINTS);
Up9x20.SetLineWeight(1);

Up9x50.SetDefaultColor(Color.GREEN);
Up9x50.SetStyle(Curve.POINTS);
Up9x50.SetLineWeight(1);

Up9x100.SetDefaultColor(Color.GREEN);
Up9x100.SetStyle(Curve.POINTS);
Up9x100.SetLineWeight(1);

Up9x200.SetDefaultColor(Color.GREEN);
Up9x200.SetStyle(Curve.POINTS);
Up9x200.SetLineWeight(1);

Dn9x20.SetDefaultColor(Color.RED);
Dn9x20.SetStyle(Curve.POINTS);
Dn9x20.SetLineWeight(1);

Dn9x50.SetDefaultColor(Color.RED);
Dn9x50.SetStyle(Curve.POINTS);
Dn9x50.SetLineWeight(1);

Dn9x100.SetDefaultColor(Color.RED);
Dn9x100.SetStyle(Curve.POINTS);
Dn9x100.SetLineWeight(1);

Dn9x200.SetDefaultColor(Color.RED);
Dn9x200.SetStyle(Curve.POINTS);
Dn9x200.SetLineWeight(1);

#VWAP Code

def cap = GetAggregationPeriod();
def errorInAggregation =
    VWapTimeFrame == VWapTimeFrame.DAY and cap >= AggregationPeriod.WEEK or
    VWapTimeFrame == VWapTimeFrame.WEEK and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");

def yyyyMmDd = GetYYYYMMDD();
def periodIndx;
switch (VWapTimeFrame) {
case DAY:
    periodIndx = yyyyMmDd;
case WEEK:
    periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));}

def vprice = volumeVwapSum / volumeSum;

plot UpClosexVwap = if close > vprice then DotOffset6 else Double.NaN;
plot DnClosexVwap = if close < vprice then DotOffset6 else Double.NaN;

UpClosexVwap.SetDefaultColor(Color.GREEN);
UpClosexVwap.SetStyle(Curve.POINTS);
UpClosexVwap.SetLineWeight(1);

DnClosexVwap.SetDefaultColor(Color.RED);
DnClosexVwap.SetStyle(Curve.POINTS);
DnClosexVwap.SetLineWeight(1);

#On Balance Volume Code

def OBV = TotalSum(Sign(close - close[1]) * volume);

plot UpObv = if OBV >= Obv[VolumeBarSensitivity] then DotOffset7 else Double.NaN;
plot DnObv = if OBV < Obv[VolumeBarSensitivity] then DotOffset7 else Double.NaN;

UpObv.SetDefaultColor(Color.GREEN);
UpObv.SetStyle(Curve.POINTS);
UpObv.SetLineWeight(1);

DnObv.SetDefaultColor(Color.RED);
DnObv.SetStyle(Curve.POINTS);
DnObv.SetLineWeight(1);

#Positive Volume Index Code

def PVI = compoundValue(1, PVI[1] + if (volume > volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100);

plot UpPvi = if PVI >= PVI[VolumeBarSensitivity] then DotOffset8 else Double.NaN;
plot DnPvi = if PVI < PVI[VolumeBarSensitivity] then DotOffset8 else Double.NaN;

UpPvi.SetDefaultColor(Color.GREEN);
UpPvi.SetStyle(Curve.POINTS);
UpPvi.SetLineWeight(1);

DnPvi.SetDefaultColor(Color.RED);
DnPvi.SetStyle(Curve.POINTS);
DnPvi.SetLineWeight(1);

#Close vs SMA Trend Code
#short-term trend is based on the 8 period SMA (length adjustable in config)
#if the current price is above the SMA, then trend will be green else red

def SMA = Average(close, CloseVsSmaTrendLength);

plot UpPriceTrend = if close > SMA then DotOffset9 else double.NaN;
plot DnPriceTrend = if close <= SMA then DotOffset9 else double.NaN;

UpPriceTrend.SetDefaultColor(Color.GREEN);
UpPriceTrend.SetStyle(Curve.POINTS);
UpPriceTrend.SetLineWeight(1);

DnPriceTrend.SetDefaultColor(Color.RED);
DnPriceTrend.SetStyle(Curve.POINTS);
DnPriceTrend.SetLineWeight(1);

#PDC Up Down Trend Code
#If current price is greater than previous day close price, then trend will be green else red

plot UpPdc = if close - close(period = "day" )[1] > 0 then DotOffset10 else Double.NaN;
plot DnPdc = if close - close(period = "day" )[1] <= 0 then DotOffset10 else Double.NaN;

UpPdc.SetDefaultColor(Color.GREEN);
UpPdc.SetStyle(Curve.POINTS);
UpPdc.SetLineWeight(1);

DnPdc.SetDefaultColor(Color.RED);
DnPdc.SetStyle(Curve.POINTS);
DnPdc.SetLineWeight(1);

#CDO Up Down Trend Code
#If current price is greater than current day open price, then trend will be green else red

plot UpCdo = if close - open(period = "day" ) > 0 then DotOffset11 else Double.NaN;
plot DnCdo = if close - open(period = "day" ) <= 0 then DotOffset11 else Double.NaN;

UpCdo.SetDefaultColor(Color.GREEN);
UpCdo.SetStyle(Curve.POINTS);
UpCdo.SetLineWeight(1);

DnCdo.SetDefaultColor(Color.RED);
DnCdo.SetStyle(Curve.POINTS);
DnCdo.SetLineWeight(1);

#PMO Up Down Trend Code
#If current price is greater than current day pre-mkt open price, then trend will be green else red

def day = GetDay();
def PMopenBar = day != day[1];
def PMO = if PMopenBar then open else PMO[1];

plot UpPmo = if close - PMO > 0 then DotOffset12 else Double.NaN;
plot DnPmo = if close - PMO <= 0 then DotOffset12 else Double.NaN;

UpPmo.SetDefaultColor(Color.GREEN);
UpPmo.SetStyle(Curve.POINTS);
UpPmo.SetLineWeight(1);

DnPmo.SetDefaultColor(Color.RED);
DnPmo.SetStyle(Curve.POINTS);
DnPmo.SetLineWeight(1);


##end
 
@floydddd @RickK ..sorry everyone. I have been swamped with work!!!!!!!! Yes!!!!! I I figured it out @RickK I will be posting that script as well.
I put a twist on the signals and you will see that as well.
It takes up less space on the chart. You will have it tomorrow as its a holiday and I will have time to add the new and/or updated script.

@Branch ......lol am a 💃 :giggle: but I appreciate the "bro" comment!!! lol, lol!!:love:

Here is a chart with the MTF together.

gcm0WJT.jpg
 
@floydddd @RickK ..sorry everyone. I have been swamped with work!!!!!!!! Yes!!!!! I I figured it out @RickK I will be posting that script as well.
I put a twist on the signals and you will see that as well.
It takes up less space on the chart. You will have it tomorrow as its a holiday and I will have time to add the new and/or updated script.

@Branch ......lol am a 💃 :giggle: but I appreciate the "bro" comment!!! lol, lol!!:love:

Here is a chart with the MTF together.

gcm0WJT.jpg
@BonBon , thanks a lot for your efforts , will you able to share it as a chart?.
 
sorry you've been so work swamps, BB, but praise be to holidays!
@Kitchasap, yes I will be sharing all the charts and updates since my last post. @Floyddd, indeed, it will be great having a 4 day weekend!!!!

Here is the Multi_Time Frame indicator. I zoomed out to show the plots(points). Also, the top row plots when 3 or more timeframes are bullish/green.

ec9pqlU.jpg
 
@BonBon and @RickK I am using the Rick's version with 50EMA ....

5nKSXNa.png


AMZN Puts:

Time Frame: 2D3m

1. Rick's HA line turned magenta
2. The price crossed 50EMA
3. Bought AMZN 2/5 3200 Put
4. Sold half when the price crossed above 50EMA
5. Sold all when AMZN started to consolidate.

Settings:

GdBcoXH.png

@AspaTrader , beautiful trading!

Question for you: How do you like this setup vs. the TrendTraderPro setup that you posted last month? [ https://usethinkscript.com/threads/trendtraderpro-indicator-for-thinkorswim.5175/#post-48468 ]. Are you still using that? I only just came upon that today. To be honest, THAT is what I was looking for when I came upon this thread posted by @BonBon . I can see benefits to both.

For the benefit of other participants in this thread, I posted an image of both side-by-side. TTP on the left with the 30 setting (plus a TEMA(50) for reference). @BonBon 's Smoothed HeikenAshi on the right with its default setting of 50 (plus a TEMA(50) for reference).

 
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.

 
Last edited:

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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