there is a study like that somewhere here on the forums. do a search for consecutive in the forumsWhat is the script (or command) for counting consecutive bars?
I have a custom study I’m trying to find a way to make a chart label that shows how many consecutive red/green bars it has on an intraday chart. “Green 3, Red 0”
I did see that one. I am not really in need of a lower study.there is a study like that somewhere here on the forums. do a search for consecutive in the forums
That's my fault. I believe I had the original code posted on another thread. Here is what I was referencing. Sorry for the confusion.your original questions was
"What is the script (or command) for counting consecutive bars?"
i sent you an example of the code
now you are requesting a different request and requesting:
a chart label. Ultimately looking for a watchlist column with a red/green box with the consecutive bar count for the zscore volume study posted above.
im not familiar with zscore and i dont see any prior mentions on this thread stating the word "zscore" nor "volume" prior to your post#11.
#Computes and plots the Zscore #Provided courtesy of ThetaTrend.com #Feel free to share the code with a link back to thetatrend.com declare lower; input price = close; input length = 20; input ZavgLength = 20; #Initialize values def oneSD = StDev(price, length); def avgClose = SimpleMovingAvg(price, length); def ofoneSD = oneSD * price; def Zscorevalue = ((price - avgClose) / oneSD); def avgZv = Average(Zscorevalue, 20); #Compute and plot Z-Score plot Zscore = ((price - avgClose) / oneSD); Zscore.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); Zscore.SetLineWeight(2); Zscore.AssignValueColor(if Zscore > 0 then Color.GREEN else Color.RED); plot avgZscore = Average(Zscorevalue, ZavgLength); avgZscore.SetPaintingStrategy(PaintingStrategy.LINE); #This is an optional plot that will display the momentum of the Z-Score average #plot momZAvg = (avgZv-avgZv); #Plot zero line and extreme bands plot zero = 0; plot two = 2; plot negtwo = -2; plot three = 3; plot negthree = -3; zero.SetDefaultColor(Color.BLACK);
def nan = double.nan; def barUp = Zscore > 0; def barDown = Zscore < 0; def barUpCount = CompoundValue(1, if barUp then barUpCount + 1 else 0, 0); def pBarUpCount = if barUpCount > 0 then barUpCount else nan; def barDownCount = CompoundValue(1, if barDown then barDownCount - 1 else 0, 0); def pBarDownCount = if barDownCount < 0 then barDownCount else nan; AddLabel(yes, "Consecutive Bar Count: " +(" "+(Round(barDownCount + barUpCount, 1))), if barUpCount >= 1 then color.green else if barDownCount <= -1 then color.red else Color.gray);
|Thread starter||Similar threads||Forum||Replies||Date|
|How to COUNT CUMULATIVE or CONSECUTIVE bars on ENTIRE CHART or SPECIFIED TIME||Tutorials||32|
|L||How to count the number of Daily high that appear||Questions||3|
|S||Count how many times stock is above 200 SMA in thinkscript||Questions||8|
|B||ThinkScript count number of bars between lows||Questions||13|
|B||Count number of tickers in watchlist||Questions||2|