Compute average highs for the day from 9:30 am


Category:
0
0

Hi pete, i like to know if is posible to start the calculation of  a study at 9:30 am, but have premarket still visble? thanks! heres the code:

def newDay = GetDay() GetDay()[1]; rec runningSumOfHighs = if newDay then high else runningSumOfHighs[1] + high; rec numberOfBarsToday = if newDay then 1 else numberOfBarsToday[1] + 1; plot averageHighsForToday = runningSumOfHighs / numberOfBarsToday;

Marked as spam
Posted by (Questions: 8, Answers: 23)
Asked on November 19, 2019 10:19 am
53 views
0
Private answer

Here you go:

input startTime = 930;
def startCalculation = SecondsTillTime(startTime) == 0;
rec runningSumOfHighs = if startCalculation then high else runningSumOfHighs[1] + high;
rec numberOfBarsToday = if startCalculation then 1 else numberOfBarsToday[1] + 1;
plot averageHighsForToday = runningSumOfHighs / numberOfBarsToday;

Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on November 19, 2019 11:40 am
0
thanks Pete You are amazing!!
( at November 19, 2019 11:56 am)
0
hey Pete Is there a way to plot from 930 only not premarket thanks in advance.
( at November 19, 2019 12:07 pm)
0
Ah, see you didn't request that from the start otherwise I would have included that. For now, I suggest you just ignore the plot during the extended hours session. In order to remove the plot from the extended hours session requires we add another input to contain the time of the last bar during the regular session. And this time will vary depending on which time frame you have selected on the chart.
( at November 19, 2019 7:05 pm)
0
Thanks Pete I guess its ok the way it is.
( at November 21, 2019 6:48 am)