jngy2k
Member
Code:
declare hide_on_daily;
declare once_per_bar;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def firstBarOfDay = if (beforeStart[1] == 1 and beforeStart == 0) or (isRollover and beforeStart == 0) then 1 else 0;
AddChartBubble(firstBarOfDay , close, "Fb", Color.white, yes);
The above script registers each bar at the start of each trading day on the chart as firstBarofDay
Whether the chart is in 5min, 15min, hourly, etc. the firstbar of each trading day will be captured.
Now, I'm trying to capture the value of each bar, specifically the High and the Low.
My feeble attempt below
Code:
def MOHigh = if firstbarofday[1] == 0 AND firstbarofday == 1 then high else MOHigh[1];
def MOLow = if firstbarofday[1] == 0 AND firstbarofday == 1 then low else MOLow[1];
Question: How would I capture the high and low of each firstbarofday bars in the chart?
The Goal: My purpose for doing so is to find the range (high-low) of each firstbarofday and compare it to today's firstbarofday.
What I will have to do after registering the High and Low values in the script is to find the Average Range of all the firstbarofday in the chart.
So thats Question 2: How do I find the Average Range of all the firstbarofday?
My feeble attempt below
Code:
def avgmo = average(mohigh,2)-average(molow,2);
AddLabel (yes, "AvgOR: " + round(avgmo,2), color.white);
Any help gladly appreciated.