Trouble shifting lower indicator plot

stockdaddy

New member
Hi, I have some very simple code that I can't for the life of me figure out why the histogram on the lower panel will not line up with its respective candles on the chart above.

This is a 610 Tick Chart of ES Futures. First lower panel is volume, second lower panel is momentum and the third lower panel is my code I call "TickSpeed".

The problem I have is my last column in the TickSpeed indicator lines up with the current column candle on the chart above and it should not! It is for the prior candle as the current TickSpeed bar can't be completed until the bar closes. I have tried offsets, Displacer() function and nothing works. I can shift the histogram bars further into the future, but I can't get them to move back one bar. (I just fails to plot) Here is a picture of the screen and the code.

Any help would be greatly appreciated.
Screenshot 2026-02-02 223050.png

Code:
# +--------------------------------------------------+
# | TickSpeed Master v9                              |
# |                                                  |
# +--------------------------------------------------+
declare lower;

# 1. Calculate the duration of the bar in seconds that just closed
def finishedBarDuration = (GetTime() - GetTime()[1]) / 1000;
def avgDuration = Average(finishedBarDuration, 10);

# Plot Histogram
plot LastBarSpeed = finishedBarDuration[0];
LastBarSpeed.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LastBarSpeed.AssignValueColor(if finishedBarDuration[1] > avgDuration[1] then GetColor(5) else GetColor(1));

# 3. Average Speed Line
plot AverageSpeed = avgDuration;
AverageSpeed.SetDefaultColor(Color.BLACK);
AverageSpeed.SetLineWeight(2);

# 4. Bar Fill Logic (Calculates on the ACTIVE bar [0])
def currentTicks = volume;
def totalTicksRequired = GetAggregationPeriod();
def completionPct = (currentTicks / totalTicksRequired) * 100;

# 5. Dynamic Labels
AddLabel(yes, " Avg Speed: " + Round(avgDuration, 1) + "s ", Color.GRAY);

# Note: Labels show current bar data
AddLabel(yes, " Last Finished Bar: " + finishedBarDuration + "s ",
    if finishedBarDuration > avgDuration then GetColor(5) else GetColor(1));

AddLabel(yes, " Active Bar Fill: " + Round(completionPct, 0) + "% ",
    if finishedBarDuration > avgDuration then GetColor(1) else GetColor(5));
 
Solution
Hi, I have some very simple code that I can't for the life of me figure out why the histogram on the lower panel will not line up with its respective candles on the chart above.

This is a 610 Tick Chart of ES Futures. First lower panel is volume, second lower panel is momentum and the third lower panel is my code I call "TickSpeed".

The problem I have is my last column in the TickSpeed indicator lines up with the current column candle on the chart above and it should not! It is for the prior candle as the current TickSpeed bar can't be completed until the bar closes. I have tried offsets, Displacer() function and nothing works. I can shift the histogram bars further into the future, but I can't get them to move back one bar. (I...
Hi, I have some very simple code that I can't for the life of me figure out why the histogram on the lower panel will not line up with its respective candles on the chart above.

This is a 610 Tick Chart of ES Futures. First lower panel is volume, second lower panel is momentum and the third lower panel is my code I call "TickSpeed".

The problem I have is my last column in the TickSpeed indicator lines up with the current column candle on the chart above and it should not! It is for the prior candle as the current TickSpeed bar can't be completed until the bar closes. I have tried offsets, Displacer() function and nothing works. I can shift the histogram bars further into the future, but I can't get them to move back one bar. (I just fails to plot) Here is a picture of the screen and the code.

Any help would be greatly appreciated.
View attachment 26955
Code:
# +--------------------------------------------------+
# | TickSpeed Master v9                              |
# |                                                  |
# +--------------------------------------------------+
declare lower;

# 1. Calculate the duration of the bar in seconds that just closed
def finishedBarDuration = (GetTime() - GetTime()[1]) / 1000;
def avgDuration = Average(finishedBarDuration, 10);

# Plot Histogram
plot LastBarSpeed = finishedBarDuration[0];
LastBarSpeed.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LastBarSpeed.AssignValueColor(if finishedBarDuration[1] > avgDuration[1] then GetColor(5) else GetColor(1));

# 3. Average Speed Line
plot AverageSpeed = avgDuration;
AverageSpeed.SetDefaultColor(Color.BLACK);
AverageSpeed.SetLineWeight(2);

# 4. Bar Fill Logic (Calculates on the ACTIVE bar [0])
def currentTicks = volume;
def totalTicksRequired = GetAggregationPeriod();
def completionPct = (currentTicks / totalTicksRequired) * 100;

# 5. Dynamic Labels
AddLabel(yes, " Avg Speed: " + Round(avgDuration, 1) + "s ", Color.GRAY);

# Note: Labels show current bar data
AddLabel(yes, " Last Finished Bar: " + finishedBarDuration + "s ",
    if finishedBarDuration > avgDuration then GetColor(5) else GetColor(1));

AddLabel(yes, " Active Bar Fill: " + Round(completionPct, 0) + "% ",
    if finishedBarDuration > avgDuration then GetColor(1) else GetColor(5));

See if this code with an offset is what you wanted.
The image shows the modified offset in the upper of the 2 lower panels with your code in the lower.

Code:
# +--------------------------------------------------+
# | TickSpeed Master v9                              |
# |                                                  |
# +--------------------------------------------------+
declare lower;

input offset = 1;
input show_only_closed_bars = yes;
input test_offset = yes;

# 1. Calculate the duration of the bar in seconds that just closed
def finishedBarDuration = (GetTime() - GetTime()[1]) / 1000;
def avgDuration = Average(finishedBarDuration[0], 10);

# Plot Histogram
plot LastBarSpeed = if show_only_closed_bars and IsNaN(close) then Double.NaN else finishedBarDuration[0 + offset];
LastBarSpeed.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
LastBarSpeed.AssignValueColor(if finishedBarDuration[1 + offset] > avgDuration[1 + offset] then GetColor(5) else GetColor(1));

#offset test
AddChartBubble(test_offset, LastBarSpeed, LastBarSpeed);

# 3. Average Speed Line
plot AverageSpeed = avgDuration;
AverageSpeed.SetDefaultColor(Color.BLACK);
AverageSpeed.SetLineWeight(2);

# 4. Bar Fill Logic (Calculates on the ACTIVE bar [0])
def currentTicks = volume;
def totalTicksRequired = GetAggregationPeriod();
def completionPct = (currentTicks / totalTicksRequired) * 100;

# 5. Dynamic Labels
AddLabel(yes, " Avg Speed: " + Round(avgDuration[0 + offset], 1) + "s ", Color.GRAY);

# Note: Labels show current bar data
AddLabel(yes, " Last Finished Bar: " + finishedBarDuration[0 + offset] + "s ",
    if finishedBarDuration > avgDuration then GetColor(5) else GetColor(1));

AddLabel(yes, " Active Bar Fill: " + Round(completionPct, 0) + "% ",
    if finishedBarDuration > avgDuration then GetColor(1) else GetColor(5));
 
Solution

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