Hi everyone,
I looked for an answer before publishing my question, then sory if someone already replied for a similar question.
So, I try to have monthly pivot (code below), and to display via SCREENER.
it don’t work, and display 0 (zero), i don’t know why !
My questions are :
- do my monthly pivot calculation is right ?
- why it don’t detect anything, and display “0”?
====CODE===
ONCE LastMonthBarIndex = BarIndex
// Monthly data setting
ONCE monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
ONCE monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
ONCE monthlyC = DClose(1)
ONCE monthlyO = Open[BarIndex - lastMonthBarIndex]
ONCE mPivot = (monthlyO + monthlyH + monthlyL + monthlyC) / 4
If month <> Month[1] then
monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
monthlyC = DClose(1)
monthlyO = Open[BarIndex - lastMonthBarIndex]
mPivot = (monthlyO + monthlyH + monthlyL + monthlyC) / 4
ENDIF
c1 = mPivot > 1
SCREENER[c1] (mPivot AS "% dPivot")//SCREENER[c3 AND c4] (mPivot < wPivot AS "% dPivot")
Thanks, and many green pips / ticks for everybody.
Jean
Please use the ‘Insert PRT Code button when putting code in your posts as it makes it far easier for others to read. I have tidied your post up for you 🙂
Hopefully someone will be along with an answer soon….
Hi and thanks for the answer…
I forget to tell that it for a screener.
I tried the solution in the link above , the screener display “0” for all products selected !
I don’t really know what is wrong !
Once lastMonthBarIndex = 0
Once monthlyH = undefined
Once monthlyL = undefined
Once mPivot = undefined
If month <> Month[1] then
monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
LastMonthBarIndex = BarIndex
mPivot = (Open + monthlyH + monthlyL + Close[1]) / 4
ENDIF
SCREENER[c1 AND c2 OR c3 AND c4] (mPivot AS "% dPivot")
thans for everything
Jean
Screeners are not applicable to MONTHLY TF, Weekly is the highest one. But you can calculate monthly pivots and use them in a lower TF.
The screener is missing variable C1, C2, C3 and C4.
Hi RobertoGozzi, thanks for the answer,
effectively, I posted the old code, here is the new :
Once lastMonthBarIndex = 0
Once monthlyH = undefined
Once monthlyL = undefined
Once mPivot = undefined
If month <> Month[1] then
monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
LastMonthBarIndex = BarIndex
mPivot = (Open + monthlyH + monthlyL + Close[1]) / 4
ENDIF
c1 = mPivot < High
SCREENER[c1] (mPivot AS "% mPivot")
Ok, there is no mean to have directly the monthly pivot, but the code above allow to calculate it (i’m not sure for the open price). once the monthly pivot calculated, i would like to display it with the last code line (SCREENER[c1] (mPivot As “% mPivot”).
But instead I only have “0” for all rows, how can i correct that ?
I hope I’m enough clear…
don’t hesitate if I can clerify more.
Thanks and cheers
Jean
I tried this code as an indicator and it works perfectly (see screenshot):
If Month<>Month[1] then
monthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
monthlyLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
lastMonthBarIndex = BarIndex
monthlyPivot = (Open + monthlyHigh + monthlyLow + Close[1]) / 4
Endif
x = high > monthlyPivot
y = -(low < monthlyPivot)
Return x OR y,0
While the same code as a screener on a 4-hour TF does not return any valid scan for HIGH > monthlypivot or LOW < monthlypivot.
I guess it may be that ProScreener can only scan at most 255 bars (the current one + the previous 254), while highest and lowest use more!
The solution could be to use it as an indicator and then code a screener that reads the values returned by the indicator.
I’ll have a try.