Hello,
I am trying to do a screener to compare the quarter high / low with the previous quarter.
I saw I can use this code for the previous quarter
trimH=max(trimH,high)
trimL=min(trimL,low)
If openMonth<>openMonth[1] then
if openmonth=4 or openmonth=7 or openmonth=10 or openmonth=1 then
trimestrialH=trimH
trimestrialL=trimL
trimL=close*100
trimH=0
endif
Endif
1/ How can I do to get current quarter H/L?
2/ How to get the preceding quarter H/L? (the one N-2)
I believe this could be easier if we have a quarterly timeframe. Is there a solution?
Many thx
Hello,
Did you get a workaround for this?
I am need to calculate quarterly pivot points and also don’t know how to get previus quarter high, low and close.
Any thoughts?
Regards
Simply store the last value in a different set of variables before storing the latest values. You can also reset the trimL to the high rather than to close*100 which is more guaranteed to work on every instrument.
trimH=max(trimH,high)
trimL=min(trimL,low)
If openMonth<>openMonth[1] then
if openmonth=4 or openmonth=7 or openmonth=10 or openmonth=1 then
trimestrialH2=trimestrialH
trimestrialL2=trimestrialL
trimestrialH=trimH
trimestrialL=trimL
trimL=high
trimH=0
endif
Endif
Hello Vonaci,
Thank you for reactivating this topic.
As reminder, The idea is to build a screener for quarter bars, starting with the instruction “timeframe (Monthly) as workaround.
Previous code allows to retrieve current high and past high only.
Is there a way to use instructions like
- trimestrialH[i], trimestrialL[i], trimestrialC[i], trimestrialO[i]
to retrieve the high, low, close and open of the bar number i in the past?
Many thanks in advance.
You could use something like this code that I’ve stolen from my OHLC MTF indicator.
lookback = 2 //How many quarters back to get results from
if openmonth <> openmonth[1] and (openmonth = 1 or openmonth = 4 or openmonth = 7 or openmonth = 10) then
quarterindex = quarterindex + 1
quarterhigh = 0
quarterlow = close
quarteropen = open
quarterclose = close
if quarterindex > lookback then
for j = 1 to barindex
if quarterindex[j] = quarterindex - lookback then
myquarterhigh = quarterhigh[j]
myquarterlow = quarterlow[j]
myquarteropen = quarteropen[j]
myquarterclose = quarterclose[j]
break
endif
next
endif
endif
quarterhigh = max(quarterhigh,high)
quarterlow = min(quarterlow,low)
quarterclose = close
return myquarterhigh, myquarterlow, myquarterclose, myquarteropen