Heiken Ashi Upper Indicator

GaMoneyDr

New member
VIP
I have combed through the forums several times, but I can't find an example of what I am looking for.

I want to find a Heikin Ashi upper indicator that will paint the candles based on Heikin Ashi conditions, but will use the actual prices on the chart.


In other words, I want to use normal candles or OHLC bars. (not Heiken Ashi averages)

And I want the condition of being red or green for the candles to be based on Heiken Ashi calculations.

These candles will reflect the real Open, High, Low, Close.


Thank you,
 
I have combed through the forums several times, but I can't find an example of what I am looking for.

I want to find a Heikin Ashi upper indicator that will paint the candles based on Heikin Ashi conditions, but will use the actual prices on the chart.


In other words, I want to use normal candles or OHLC bars. (not Heiken Ashi averages)

And I want the condition of being red or green for the candles to be based on Heiken Ashi calculations.

These candles will reflect the real Open, High, Low, Close.


Thank you,

1. In researching this, as far as moving averages, TOS uses the normal candle prices even on a heiken ashi candle chart
2. Here is chart in the left panel with an adaptive moving average set to use both normal candle prices and another using the heiken ashi candle prices. You can see the differences between the two plots.
2a. Both have the same heiken ashi coloring scheme.
3. On the right panel is a normal candle chart with normal coloring, but same plot as heiken ashi plot using normal candle prices with heiken ashi coloring.
4. Heiken Ashi candle prices were used in the codes below.
def HAclose = ohlc4;
def HAopen = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[1] + close[1]) / 2);
def HAhigh = Max(Max(high, HAopen), HAclose);
def HAlow = Min(Min(low, HAopen), HAclose);
5. Link to grid in image https://tos.mx/S9SGfS6

What you requested: Normal Candles Moving Average with Heiken Ashi Coloring while on a chart using Heiken Ashi Candles
Screenshot 2024-03-02 062742.png
Code:
#AdaptiveMA_NormalCandles_HeikenAshi_Coloring
#

input price = close;
input length = 10;
input highLowLength = 10;

def multiplier1 = 2 / (length + 1);
def denom = Highest(high, highLowLength) - Lowest(low, highLowLength);
def multiplier2 = if denom == 0 then 1 else AbsValue((close - Lowest(low, highLowLength)) - (Highest(high, highLowLength) - close)) / denom;
def alpha = multiplier1 * (1 + multiplier2);
def ma = CompoundValue(1, ma[1] + alpha * (price - ma[1]), Average(price, length));

plot AEMA = ma;
#AEMA.SetDefaultColor(GetColor(1));

def HAclose = ohlc4;
def HAopen  = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[1] + close[1]) / 2);
def HAhigh  = Max(Max(high, HAopen), HAclose);
def HAlow   =  Min(Min(low, HAopen), HAclose);

AEMA.AssignValueColor(if HAopen > HAclose then Color.RED else Color.GREEN);

#
Moving Average using Heiken Ashi candle prices
Code:
#AdaptiveMA_HeikenAshi_Candles
#

def HAclose = ohlc4;
def HAopen  = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[1] + close[1]) / 2);
def HAhigh  = Max(Max(high, HAopen), HAclose);
def HAlow   =  Min(Min(low, HAopen), HAclose);


def price = HAclose;
input length = 10;
input highLowLength = 10;

def multiplier1 = 2 / (length + 1);
def denom = Highest(HAhigh, highLowLength) - Lowest(HAlow, highLowLength);
def multiplier2 = if denom == 0 then 1 else AbsValue((HAclose - Lowest(HAlow, highLowLength)) - (Highest(HAhigh, highLowLength) - HAclose)) / denom;
def alpha = multiplier1 * (1 + multiplier2);
def ma = CompoundValue(1, ma[1] + alpha * (price - ma[1]), Average(price, length));

plot AEMA = ma;
AEMA.AssignValueColor(if HAopen > HAclose then Color.RED else Color.GREEN);

#
 
Last edited:
The chart you show on the right appears to have the "actual" candles. Not the HA Averages.

Is there any way to get the actual candles on the right to appear with the colors of the candles on the left?


In doing so, I would have the actual prices along with the Heiken Ashi candle trend info.


Thank you for your reply.
 
The chart you show on the right appears to have the "actual" candles. Not the HA Averages.

Is there any way to get the actual candles on the right to appear with the colors of the candles on the left?


In doing so, I would have the actual prices along with the Heiken Ashi candle trend info.


Thank you for your reply.

The code that I provided above can be used on a candle chart. I thought you were using a heiken ashi upper chart and wanted to be sure that the moving averages were using normal chart prices, which they do there. The candle chart was just to show that the moving averages plotted that same.

Here is one of the codes I provided above plugged into a normal candle chart.
Screenshot 2024-03-02 163406.png
Code:
#AdaptiveMA_NormalCandles_HeikenAshi_Coloring
#

input price = close;
input length = 10;
input highLowLength = 10;

def multiplier1 = 2 / (length + 1);
def denom = Highest(high, highLowLength) - Lowest(low, highLowLength);
def multiplier2 = if denom == 0 then 1 else AbsValue((close - Lowest(low, highLowLength)) - (Highest(high, highLowLength) - close)) / denom;
def alpha = multiplier1 * (1 + multiplier2);
def ma = CompoundValue(1, ma[1] + alpha * (price - ma[1]), Average(price, length));

plot AEMA = ma;
#AEMA.SetDefaultColor(GetColor(1));

def HAclose = ohlc4;
def HAopen  = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[1] + close[1]) / 2);
def HAhigh  = Max(Max(high, HAopen), HAclose);
def HAlow   =  Min(Min(low, HAopen), HAclose);

AEMA.AssignValueColor(if HAopen > HAclose then Color.RED else Color.GREEN);

#
 
I have combed through the forums several times, but I can't find an example of what I am looking for.

I want to find a Heikin Ashi upper indicator that will paint the candles based on Heikin Ashi conditions, but will use the actual prices on the chart.


In other words, I want to use normal candles or OHLC bars. (not Heiken Ashi averages)

And I want the condition of being red or green for the candles to be based on Heiken Ashi calculations.

These candles will reflect the real Open, High, Low, Close.


Thank you,

see if this is what you want
it looks at HA stats and determines if the a HA candle is up or down. then colors the normal candles

Code:
#heiken_ashi_color_bars

#https://school.stockcharts.com/doku.php?id=chart_analysis:heikin_ashi
#HA-Close = (Open(0) + High(0) + Low(0) + Close(0)) / 4
#HA-Open = (HA-Open(1) + HA-Close(1)) / 2
#HA-High = Maximum of the High(0), HA-Open(0) or HA-Close(0)
#HA-Low = Minimum of the Low(0), HA-Open(0) or HA-Close(0)

def HAclose = ohlc4;
def HAopen = CompoundValue(1, (HAopen[1] + HAclose[1]) / 2, (open[0] + close[0]) / 2);
def HAhigh = Max(Max(high, HAopen), HAclose);
def HAlow = Min(Min(low, HAopen), HAclose);

def haup = HAclose > HAopen;
def hadwn = HAclose < HAopen;

AssignPriceColor(if haup then color.green else if hadwn then color.red else color.gray);
#
 

Attachments

  • img1.JPG
    img1.JPG
    79 KB · Views: 64

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
331 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