I have been trying to code a monthly version of the inside bar breakout failure for a while but to no avail. Below is the code I use for Daily and Weekly.
c1= high[1] < high[2]
c2= low[1] > low[2]
insidebar = c1 and c2
insidebarbreak = high[0]>high[1] or low[0]<low[1]
reversal = close[0]<high[1] and close[0]>low[1]
insidebarfailure = insidebar and insidebarbreak and reversal
screener[insidebarfailure]
This is my attempt at the monthly
////CURRENT MONTH Open & Close////
If Month<>Month[1] then
MCOpen = Open[0]
endif
MCClose = Close[0]
////CURRENT MONTH High & Low////
//unsure and stuck here
////PREVIOUS MONTH Open & Close////
If Month<>Month[1] then
MCOpen = Open[1]
endif
MCClose = Close[1]
////PREVIOUS MONTH High & Low////
If Month<>Month[1] and barindex>20 then
MPHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
MPLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
lastMonthBarIndex = BarIndex
ENDIF
As you can see I am stuck trying to get this month’s or the current month’s High and Low. Any suggestions or tips? Thank you.
There you go:
//MONTH OHLC //
//
If Month<>Month[1] then
MCClose = close[1] //close of previous month
MCOpen = CurOpen //open of previous month
CurOpen = open //open of new month (current month)
MPHigh = CurHigh //previous monthly high
MPlow = CurLow //previous monthly low
CurHigh = high //new monthly high
CurLow = low //new monthly low
ENDIF
CurHigh = max(CurHigh,high) //update High
CurLow = min(CurLow,low) //update Low