Price of Moving Average at Specific Time


Category:
0
0

hello kind sir I’m looking for a script to display a chart label for a exponential moving average (10) ‘s current price  for premarket open and market open.  Is that possible?

RESOLVED
Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on March 5, 2023 9:21 pm
60 views
1
Private answer

This solution will only work if you have included extended trading hours on your chart. I have included user input to allow adjustments to the regular session start time as well as the moving average elements.

input sessionStartTime = 930;
input maLengthOne = 10;
input maTypeOne = AverageType.EXPONENTIAL;
input maPriceOne = close;
plot maOne = MovingAverage(maTypeOne, maPriceOne, maLengthOne);
def newDay = GetDay() <> GetDay()[1];
rec pmAverage = if newDay then maOne else pmAverage[1];
rec regAverage = if SecondsFromTime(sessionStartTime) == 0 then maOne else regAverage[1];
AddLabel(yes, Concat("PM Avg: ", Round(pmAverage, 2)), Color.WHITE);
AddLabel(yes, Concat("Reg Avg: ", Round(regAverage, 2)), Color.GRAY);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 6, 2023 4:55 pm