I use the getlast####() == get###() logic
for a bunch of code.
I am trying to think of an elegant way to approximate it for quarter and 3day as TOS doesn't have getlast() or get() for those TFs. I want to treat the current quarter or 3day different and I am using them on lower TF charts so I need to find a way to refer to the current quarter or current 3 day for a plot that uses their aggregates on lower TF charts.
I didn't explain it well. I want to reference open only if its the current bar, otherwise I want to refer to low. I usually specify the current bar by using GetMonth()==Getlastmonth() for example for month bars, but that isn't available for Threeday and for Quarter (I use them across different tfs so can't specify the last bar explicitly). I came up with a work around where I will have to update occasionally when a new candle begins.
In fact, I should use aggregationperiod.quarter in both lines so I am not mixing aggregations in the code.

for a bunch of code.
I am trying to think of an elegant way to approximate it for quarter and 3day as TOS doesn't have getlast() or get() for those TFs. I want to treat the current quarter or 3day different and I am using them on lower TF charts so I need to find a way to refer to the current quarter or current 3 day for a plot that uses their aggregates on lower TF charts.
I didn't explain it well. I want to reference open only if its the current bar, otherwise I want to refer to low. I usually specify the current bar by using GetMonth()==Getlastmonth() for example for month bars, but that isn't available for Threeday and for Quarter (I use them across different tfs so can't specify the last bar explicitly). I came up with a work around where I will have to update occasionally when a new candle begins.
In fact, I should use aggregationperiod.quarter in both lines so I am not mixing aggregations in the code.
Code:
def op = open(period = aggregationPeriod.QUARTER);
def openref = if getyYYYMMDD() == 20240701 then open(period=aggregationPeriod.DAY) else openref[1];
def stt = op==openref;
Last edited by a moderator: