Referencing previous day close price on intraday chart


Category:
0
0

Let’s say I am looking at an intraday chart on Tuesday morning. How would I reference Friday’s closing price?

Marked as spam
Posted by (Questions: 8, Answers: 5)
Asked on January 26, 2019 11:03 am
210 views
0

Is there any way to incorporate …

def fri = (GetDayOfWeek(GetYYYYMMDD()) == 5);

to specifically reference friday’s close? On holidays like MLK day, there was no trading on Monday so by doing something like referencing the daily close price from two days ago will not always work. For example:

def tuesday_close_reference = close(period = AggregationPeriod.DAY)[2];

Referencing two closes ago will not work this week because that would refer to Thursday’s close price as there was no trading on Monday.

Can we directly reference the close of when (GetDayOfWeek(GetYYYYMMDD()) == 5) and have that value update every friday?

( at January 26, 2019 11:19 am)
0
Private answer

I suggest you add a test to see if previous trading day == Monday. When true, we know there was trading on Monday. So build a nested if/then/else statement to check if Monday trade data is there. And if so, grab the close from 2 bars ago (Friday), and if not then grab the close from 1 bar ago.

Marked as spam
Posted by (Questions: 37, Answers: 4108)
Answered on January 27, 2019 11:50 am