use HA candles, the stock price appears delayed

AlAbed

New member
VIP
This indicator is used specifically for heiken ashi candles. It indicates a reversal signal and only appears when a high volume doji candle forms
# Precision Trend Scalping (Non-Repaint, Intuitive, Plot on Last Confirming Bar)
# - Non-repainting: uses only completed prior candles for confirmation
# - Intuitive mapping: Above EMA -> flat bottoms (bullish), Below EMA -> flat tops (bearish)
# - Plots signal on the LAST confirming candle by shifting back minConsecutiveCandles bars
mmyRQ07.png


Code:
# Precision Trend Scalping (Non-Repaint, Intuitive, Plot on Last Confirming Bar)
# - Non-repainting: uses only completed prior candles for confirmation
# - Intuitive mapping: Above EMA -> flat bottoms (bullish), Below EMA -> flat tops (bearish)
# - Plots signal on the LAST confirming candle by shifting back minConsecutiveCandles bars

declare upper;

input emaLength = 100;
input minConsecutiveCandles = 2;
input maxWickRatio = 0.05;
input maxWickTicks = 2;
input maxDojiBodyRatio = 0.3;
input minWickTotalRatio = 0.7;

# -------------------------
# EMA
# -------------------------
def ema = ExpAverage(close, emaLength);
plot EMAline = ema;
EMAline.SetDefaultColor(Color.WHITE);

# -------------------------
# Heikin Ashi (Manual Calculation - Compatible)
# -------------------------

rec haClose = (open + high + low + close) / 4;

rec haOpen =
    if BarNumber() == 1
    then (open + close) / 2
    else (haOpen[1] + haClose[1]) / 2;

def haHigh = Max(high, Max(haOpen, haClose));
def haLow  = Min(low, Min(haOpen, haClose));

def haBullish = haClose > haOpen;
def haBearish = haClose < haOpen;

def haTotalSize = haHigh - haLow;
def haBodySize  = AbsValue(haClose - haOpen);

def haUpperWick = haHigh - Max(haOpen, haClose);
def haLowerWick = Min(haOpen, haClose) - haLow;

def wickTolerance = TickSize() * maxWickTicks;
def okSize = haTotalSize > 0;

def haFlatBottom =
    haBullish and okSize and
    (haLowerWick / haTotalSize <= maxWickRatio) and
    (haLowerWick <= wickTolerance);

def haFlatTop =
    haBearish and okSize and
    (haUpperWick / haTotalSize <= maxWickRatio) and
    (haUpperWick <= wickTolerance);

def haDoji =
    okSize and
    (haBodySize / haTotalSize <= maxDojiBodyRatio) and
    ((haUpperWick + haLowerWick) / haTotalSize >= minWickTotalRatio);

def prevTotal = haHigh[1] - haLow[1];
def largerThanPrev = haTotalSize >= prevTotal;

# -------------------------
# EMA zones (regular candles)
# -------------------------
def fullyAboveEMA = low > ema;
def fullyBelowEMA = high < ema;

# -------------------------
# Consecutive confirmation using ONLY prior completed bars:
# Require the last N bars (1..N) to all be flat.
# -------------------------
def allPriorFlatBottoms =
    (fold fb_i = 1 to minConsecutiveCandles + 1
     with fb_flag = 1
     do fb_flag * (if GetValue(haFlatBottom, fb_i) then 1 else 0)) == 1;

def allPriorFlatTops =
    (fold ft_i = 1 to minConsecutiveCandles + 1
     with ft_flag = 1
     do ft_flag * (if GetValue(haFlatTop, ft_i) then 1 else 0)) == 1;

# Confirmed signals (true on the bar AFTER the last confirming bar)
def bullishConfirmed = fullyAboveEMA and allPriorFlatBottoms and haDoji and largerThanPrev;
def bearishConfirmed = fullyBelowEMA and allPriorFlatTops and haDoji and largerThanPrev;

# Shift plots back so the arrow prints on the LAST confirming bar
plot Bull = bullishConfirmed[minConsecutiveCandles];
Bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Bull.SetDefaultColor(Color.LIME);
Bull.SetLineWeight(3);

plot Bear = bearishConfirmed[minConsecutiveCandles];
Bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Bear.SetDefaultColor(Color.RED);
Bear.SetLineWeight(3);
I’ve noticed that when I use HA candles, the stock price appears delayed in TOS. Is there a reason for this, and how can I fix it?
 
Solution
I’ve noticed that when I use HA candles, the stock price appears delayed in TOS. Is there a reason for this, and how can I fix it?


Your question is too broad to be able to pinpoint the problem.
If your charts themselves are taking time to load or the data feed loading price is delayed, it is unlikely to be due to the use of Heiken Ashi candles.

Put this grid on your screen. If you find that the price in the box on the top menu bar in the left HA candle chart is different from the regular candle chart on the right with no other indicators, take a screenshot and post it so contributors can see what you are seeing.

shared grid link: http://tos.mx/!JtsgXFPn MUST follow these instructions for loading...
I’ve noticed that when I use HA candles, the stock price appears delayed in TOS. Is there a reason for this, and how can I fix it?


Your question is too broad to be able to pinpoint the problem.
If your charts themselves are taking time to load or the data feed loading price is delayed, it is unlikely to be due to the use of Heiken Ashi candles.

Put this grid on your screen. If you find that the price in the box on the top menu bar in the left HA candle chart is different from the regular candle chart on the right with no other indicators, take a screenshot and post it so contributors can see what you are seeing.

shared grid link: http://tos.mx/!JtsgXFPn MUST follow these instructions for loading shared links.
jUGA2rp.png


If your question is why the HA candles show a different price on the right axis from the regular candles.
It is because HA candles are an average of price; regular candles show the actual price.
 
Solution

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

I’ve noticed that when I use HA candles, the stock price appears delayed in TOS. Is there a reason for this, and how can I fix it?
Yes, what you’re seeing is completely normal, and it’s not actually a data delay. It’s how Heikin Ashi (HA) candles are constructed. Heikin Ashi is not real price. It’s a smoothed, synthetic candle built from averages. Some folks use both HA and "regular" candles either on side-by-side charts or on the same chart overlaid.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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