hi i am posting a scrip i don't know how to say don't want the idicator to show all historical line is the a way to say only last few line thanks
Code:
input showOnlyLastPeriod = yes; # Show only the latest 16:14 line
input showLabel = yes; # Toggle label on/off
def bn = BarNumber();
# Detect the bar that contains 16:14
def contains1614 = SecondsTillTime(1614) <= 0 and SecondsTillTime(1614)[1] > 0;
# Capture the close of that bar and freeze it
def frozenClose1614 = if contains1614 then close else frozenClose1614[1];
# Track bar number for showOnlyLastPeriod
def ybar = if contains1614 then bn else Double.NaN;
# Plot the 16:14 close line
plot p1614 = if showOnlyLastPeriod and bn < HighestAll(ybar) then Double.NaN else frozenClose1614;
p1614.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
p1614.SetDefaultColor(Color.YELLOW);
p1614.SetLineWeight(2);
# Add a label showing the frozen 16:14 close price
AddLabel(showLabel,
"16:14 Close: " + AsText(frozenClose1614, NumberFormat.TWO_DECIMAL_PLACES),
p1614.TakeValueColor());