AlfyParticipant
Average
Good morning guys, happy new year. i found this code for the “pocket pivot” indicator on the site but i think its coded incorrectly and i wondered if one of you guys could help me fix it please? The indicator should find when the volume of a stock on an “up day” is greater than the volume of the last 10 days “down days.” I believe the code I’ve posted just looks back at the last 10 days rather than the last 10 days “down days.” Any help as always would be appreciated.
Best regards
daystoconfirmuptrend = 50
cPrc1 = (close > Average[daysToConfirmUpTrend](close) AND Close > open)
maxDay = 10
maxDownDay = 0
maxdown = 0
FOR d = 1 TO maxDay DO
r = Close[d] - open[d]
IF r <0 and volume[d]> maxDown THEN
maxDown = volume[d]
maxDownDay = d
ENDIF
NEXT
IF maxDownday = 0 THEN
maxDowndayVol=0
ELSE
maxDowndayvol = volume[maxdownday]
ENDIF
cVol2 = (volume > maxDownDayvol)
Cprc2 = (close >= Average[20](close))
Cprc3 = (close CROSSES OVER Average[10](close) OR Close CROSSES OVER Average[50](close))
cPrc11 = (close > (high + low) *0.5)
Cprc13 = (close[1] < highest[65](close))
ind1 = (cPrc1 AND cPrc2 AND (cPrc3 OR 1) AND cVol2 AND (cPrc11 OR 1) AND (cPrc13 OR 1))
RETURN ind1 COLOURED (0,0,200) AS "Pivot Pocket"
is greater than the volume of the last 10 days “down days.”
Do you mean greater than the last 10 down days volumes combined or greater than the largest volume day in the last 10 down days?
AlfyParticipant
Average
Sorry, i wasnt clear. i mean greater than the largest volume down day in the last 10 down days. Thanks for your reply!
This code checks for greater than the largest volume day in the last 10 down days. I left all your other conditions in the code.
daystoconfirmuptrend = 50
cPrc1 = (close > Average[daysToConfirmUpTrend](close) AND Close > open)
maxDay = 10
maxDownDayVol = 0
maxdown = 0
count = 0
if barindex >= maxday then
FOR d = 1 TO barindex DO
IF Close[d] < open[d] THEN
count = count + 1
maxDownDayVol = max(volume[d],maxdowndayvol)
if count = maxday then
break
endif
ENDIF
NEXT
cVol2 = (volume > maxDownDayvol)
Cprc2 = (close >= Average[20](close))
Cprc3 = (close CROSSES OVER Average[10](close) OR Close CROSSES OVER Average[50](close))
cPrc11 = (close > (high + low) *0.5)
Cprc13 = (close[1] < highest[65](close))
ind1 = (cPrc1 AND cPrc2 AND (cPrc3 OR 1) AND cVol2 AND (cPrc11 OR 1) AND (cPrc13 OR 1))
endif
RETURN ind1 COLOURED (0,0,200) AS "Pivot Pocket"
This does the other option. It is unlikely to get many hits as adding together the volume of 10 down day candles equals a lot of volume to have in just one up candle!
daystoconfirmuptrend = 50
cPrc1 = (close > Average[daysToConfirmUpTrend](close) AND Close > open)
maxDay = 10
maxDownDayVol = 0
maxdown = 0
count = 0
if barindex >= maxday then
FOR d = 1 TO barindex DO
IF Close[d] < open[d] THEN
count = count + 1
maxDownDayVol = maxdowndayvol+volume[d]
if count = maxday then
break
endif
ENDIF
NEXT
cVol2 = (volume > maxDownDayvol)
Cprc2 = (close >= Average[20](close))
Cprc3 = (close CROSSES OVER Average[10](close) OR Close CROSSES OVER Average[50](close))
cPrc11 = (close > (high + low) *0.5)
Cprc13 = (close[1] < highest[65](close))
ind1 = (cPrc1 AND cPrc2 AND (cPrc3 OR 1) AND cVol2 AND (cPrc11 OR 1) AND (cPrc13 OR 1))
endif
RETURN ind1 COLOURED (0,0,200) AS "Pivot Pocket"
I notice that your description requires an up day – this is not in the original code! Here is a pure version that just does what you ask for. It looks for a green day that has volume greater than the biggest volume in the last ten down days.
maxDay = 10
maxDownDayVol = 0
count = 0
if barindex >= maxday then
FOR d = 1 TO barindex DO
IF Close[d] < open[d] THEN
count = count + 1
maxDownDayVol = max(volume[d],maxdowndayvol)
if count = 10 then
break
endif
ENDIF
NEXT
ind1 = (volume > maxDownDayvol) and (close > open)
endif
RETURN ind1 COLOURED (0,0,200) AS "Pivot Pocket"
AlfyParticipant
Average
Fabulous, thanks so much for your help.
AlfyParticipant
Average
One final question if i may? How does one turn the indicator into a screener please?
daystoconfirmuptrend = 50
cPrc1 = (close > Average[daysToConfirmUpTrend](close) AND Close > open)
maxDay = 10
maxDownDayVol = 0
maxdown = 0
count = 0
if barindex >= maxday then
FOR d = 1 TO barindex DO
IF Close[d] < open[d] THEN
count = count + 1
maxDownDayVol = max(volume[d],maxdowndayvol)
if count = maxday then
break
endif
ENDIF
NEXT
cVol2 = (volume > maxDownDayvol)
Cprc2 = (close >= Average[20](close))
Cprc3 = (close CROSSES OVER Average[10](close) OR Close CROSSES OVER Average[50](close))
cPrc11 = (close > (high + low) *0.5)
Cprc13 = (close[1] < highest[65](close))
ind1 = (cPrc1 AND cPrc2 AND (cPrc3 OR 1) AND cVol2 AND (cPrc11 OR 1) AND (cPrc13 OR 1))
endif
RETURN ind1 COLOURED (0,0,200) AS "Pivot Pocket"
Just call it from a screener:
result = call "Pocket Pivot"
SCREENER[result]
Change the name from Pocket Pivot if you have called the indicator something different.
AlfyParticipant
Average
Sorry, im sure im doing something stupid but i get a syntax error “This variable is not used in the code:maxdown”. Would you mind taking a look and tell me where im going wrong?
Thanks for all your help.
Best regards
daystoconfirmuptrend = 50
cPrc1 = (close > Average[daysToConfirmUpTrend](close) AND Close > open)
maxDay = 10
maxDownDayVol = 0
maxdown = 0
count = 0
if barindex >= maxday then
FOR d = 1 TO barindex DO
IF Close[d] < open[d] THEN
count = count + 1
maxDownDayVol = max(volume[d],maxdowndayvol)
if count = maxday then
break
endif
ENDIF
NEXT
cVol2 = (volume > maxDownDayvol)
Cprc2 = (close >= Average[20](close))
Cprc3 = (close CROSSES OVER Average[10](close) OR Close CROSSES OVER Average[50](close))
cPrc11 = (close > (high + low) *0.5)
Cprc13 = (close[1] < highest[65](close))
ind1 = (cPrc1 AND cPrc2 AND (cPrc3 OR 1) AND cVol2 AND (cPrc11 OR 1) AND (cPrc13 OR 1))
endif
screener[ind1]
AlfyParticipant
Average
Sir, im sorry to be a pain…i just took a look at the indicator you kindly helped me with and it doesn’t seem to do what i wanted it to. I wanted it to tell me: if volume on a up day was greater than the highest volume of the previous 10 down days. I just looked manually at an ETF (PHSP) which i think should have done this today but the indicator didnt pick it up?
maxDay = 10
maxDownDayVol = 0
maxdown = 0
count = 0
if barindex >= maxday then
FOR d = 1 TO barindex DO
IF Close[d] < open[d] THEN
count = count + 1
maxDownDayVol = max(volume[d],maxdowndayvol)
if count = maxday then
break
endif
ENDIF
NEXT
cVol2 = (volume > maxDownDayvol)
endif
RETURN cVol2 COLOURED (0,0,200)
The code you posted is not the same as I posted in this post:
Pocket pivot indicator
Look at line 16 – there is an additional condition for this current candle being green.