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.
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.
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));