Pivot display for the time period from 9 to 11:30 AM EST.


Hi Pete,

Can you please help for a code which can display a label displaying pivot( (H+L+C)/3 ) for the period of 9 to 11:30 AM EST and 9:30 to 11:30 AM est.

Thank you,


Marked as spam
Posted by (Questions: 29, Answers: 40)
Asked on December 12, 2019 3:12 pm
So you want the code to determine the highest high and the lowest low that appears between 9 am and 11:29:59 am? Then get the closing value of the bar just before 11:30 am? Then from those values you want to compute the (H + L + C) / 3 pivot and plot that for the rest of the trading day? I don't understand why you listed the time spans twice: "for the period of 9 to 11:30 AM EST and 9:30 to 11:30 AM est." Once we clear up these details I should be able to provide a solution.
( at December 12, 2019 7:47 pm)
Hi Pete, Yes please. It is exactly the same what you understood. Two different time spans are due to the Nymex open and Indices open time difference. Can the previous day’s computed pivot line plot stay on next day as well, if so that would be good.
( at December 13, 2019 2:58 pm)
Private answer

I decided to make this flexible by including only a signal label and user inputs for the start and end time as well as the label text. This permits you to add this to the chart as many times as you like. Each one will create a label and you can customize each one to display the specified time span and label description.

input startTime = 900;
input endTime = 1129;
input labelText = "NYMEX Pivot: ";
def targetPeriod = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;
rec trackTargetHigh = if targetPeriod and !targetPeriod[1] then high else if targetPeriod and high > trackTargetHigh[1] then high else trackTargetHigh[1];
rec trackTargetLow = if targetPeriod and !targetPeriod[1] then low else if targetPeriod and low > 0 and low < trackTargetLow[1] then low else trackTargetLow[1];
rec trackTargetClose = if !targetPeriod and targetPeriod[1] then close[1] else trackTargetClose[1];
def pivot = Round((trackTargetLow + trackTargetHigh + trackTargetClose) / 3, 2);
AddLabel(yes, Concat(labelText, pivot), Color.WHITE);

I did not include the ability to display the pivot value from the previous day.

Marked as spam
Posted by (Questions: 37, Answers: 3100)
Answered on December 14, 2019 9:18 am
Thank you Pete. This is perfect.
( at December 14, 2019 2:38 pm)