I agree the above code works...The code doesn't work when I use X_date and Y_date ;basically calculating the number of days from high to low.
def num_trading_days = absValue(CountTradingDays(X_Date, Y_Date));
def num_calendar_days = absvalue(DaysFromDate(X_Date) - DaysFromDate(Y_Date) + 1);
input anchor_date = 20210801...
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);
DID you go the response for this mate ? I am looking for the sameHello. Can anyone in the community help me modify the thinkscript below to return the current number of trading days (vs calendar days) or the number of bars “after” a predefined low, and assign a desired color to the label?
input anchor_date = 20201030;
def num_days = DaysFromDate(anchor_date);
AddLabel(yes, (DaysFromDate(anchor_date) + " TD from Low"));
Given the above, today (11/19/20) is 14 trading days or bars “after” the 10/30/20 low.
Thanks very much!
DID you go the response for this mate ? I am looking for the same
input anchor_date = 20201030; def last_trading_day = HighestAll(if !IsNaN(close) and IsNaN(close[-1]) then GetYYYYMMDD() else Double.NaN); def num_days = CountTradingDays(anchor_date, last_trading_day); AddLabel(yes, (num_days + " TD from & including " + asprice(anchor_date)));
Thank you Bud......My actual question in the forum if you figure out let me know.This uses counttradingdays function, which counts trading days from and including the dates in it. You can adjust that computation if you want to exclude either the from or to dates from the computation.
Thank you Bud......My actual question in the forum if you figure out let me know.
From previous month I want to calculate two things No of trading days from High to low (or low to high whichever comes first) and same no. of calendar days. I am working on a project I want to finish this weekend.
For example : In August Spy have low of 300 on august 1st and high of 400 august 13th . Then the trading days will be 10 days and calendar days = 13 days..
input anchor_date = 20210801; input to_date = 20210813; def num_trading_days = CountTradingDays(anchor_date, to_date); def num_calendar_days = DaysFromDate(anchor_date) - DaysFromDate(to_date) + 1; AddLabel(yes, "TDays: " + num_trading_days + " | CDays: " + num_calendar_days + " - from & including ... " + AsPrice(anchor_date) + " to " + AsPrice(to_date), color.white );
|Thread starter||Similar threads||Forum||Replies||Date|
|How can I count Total Orders traded?||Questions||1|
|P||Time to count the uptrend or downtrend||Questions||0|
|I||Convert ProRealTime Pivot Points (High/Low), also known as Bar Count Reversals||Questions||0|
|P||Display condition and condition count||Questions||1|