Need help plotting open price of year. In Tos.


Category:
0
0

I am trying to automate some of my work. On my pre-market checklist grid. I want to plot the open price on the first day of the year and stay(not change throughout the whole year for the e-mini or any market I monitor. I got the month to work. Can’t get the year it always wants to plot the Jan 3rd price.

Here is what I have got so far.

Thanks for your assistance

Kevin

 

input yearOpen = 2240.75;
#Def yo = open[evaluateBar];
def yo = YearOpen;
#def yo = if GetlastYear() == GetYear() then open else Double.NaN;

AddLabel(showLabel, ” Year Open ” + GetDay()[evaluateBar] + ” Open ” + yo + ” “, Color.PLUM);
AddChartBubble(lastBar and showlookback, yo, ” YO ” + yo, Color.CYAN, if yo > close then Yes else no);

plot openY = yo;
openY.SetStyle(Curve.SHORT_DASH);
openY.SetLineWeight(3);
openY.SetDefaultColor(GlobalColor(“year”));

 

 

 

 

 

Attachments:
Marked as spam
Posted by (Questions: 2, Answers: 7)
Asked on January 13, 2017 7:27 pm
158 views
0
Private answer

I have a couple of comments. One is that the code you posted produced numerous compiler errors. So I started from scratch. Not a perfect solution because mine is plotting the daily close for all years prior to the current year. But for the current year it does indeed plot the Opening price for 2017, which is January 3rd. For the symbol /ES, that value is 2240.75.

rec yearOpen = CompoundValue(1, if GetLastYear() <> GetYear() then open[-1] else yearOpen[1], Double.NaN);
plot data = yearOpen;

Hope it helps!

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 13, 2017 8:33 pm