2nd derivative test for volume
Forums › ProRealTime English forum › ProScreener support › 2nd derivative test for volume
- This topic has 9 replies, 4 voices, and was last updated 2 years ago by Khaled.
-
-
09/24/2021 at 6:35 PM #178327
Good day, I hope you are having a great weekend.
Has anyone seen anyone making an indicator or scanner with the second derivative test of preferably volume ( if not, its price is ok too)? The second derivative test is basically the slope of the slope. It is a similar relationship to acceleration and speed.
Rough concept code will be like this:
2nd derivative test for volume12345678910111213141516171819202122///////////////1st derivative test ///////////////IF (Volume[2] - Volume[1]) < -1 THENSlopeDecending2=-1IF (Volume[1] - Volume) < -1 THEN // the above decending has been contenuaslly going downSlopeDecending1=-1///////////////2nd derivative test ///////////////IF (Volume[2] - Volume[1]) < (Volume[1] - Volume) THENSteepness=-1 //Sharply falling stringent downELSE //The above decending is ending soonSteepness= 1 //Bearish is ending and recovering to be Bull soonReference:
09/27/2021 at 3:25 PM #178574<u>FD First derivative (slope)</u>
FD = Close – Close[n]
When FD = 0 then there is a relative maximum or minimum value.
<u>SD Second derivative (slope of the slope)</u>
SD = FD – FD[n]
When FD = 0 and SD < 0 then there is a relative maximum value.
When FD = 0 and SD > 0 then there is a relative minimum value.
12345678FD = Close - Close[n]SD = FD - FD[n]If FD = 0 and SD > 0 thenBuy x contract at MarketElsIf FD = 0 and SD < 0 thenSellShort x contract at MarketEndIf1 user thanked author for this post.
09/27/2021 at 3:42 PM #178576Line 1 will almost never return 0, so lines 4 and 6 will almost never be true.
Could lines 4 and 6 be If FD <> 0 and ?
09/27/2021 at 4:07 PM #178580Seems to work fine but you can use “round” if you like…
FD must be equal to zero because at this value there is a relative max. value or relative min. value.2 users thanked author for this post.
09/27/2021 at 5:33 PM #178588It works. Thank you 🙂
09/28/2021 at 3:56 PM #178663Thank you very much, Rob and Js!! After using “” If FD <> 0 and “” I did it!! It is working.
I still have to clean up the code but here is the progress so far.
YS_dérivé123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100Defparam CalculateOnLastBars = 5000////AvgPeriod=14 // opens & closes 1 day back//pubs = ( Dclose(2) - Dopen(1) ) // yesterday close -> today open//profs = ( Dopen(1) - Dclose(1) ) // today open -> today close//pubsAvg = average[AvgPeriod](pubs)//profsAvg = average[AvgPeriod](profs)//return pubsAvg as "pub", profsAvg as "pros", 0 as "zero line"fade1=10fade2=100fade3=200dis1=1.5dis2=2.5dis3=3dis4=4.5dis5=5plus1=1atr = averagetruerange[10](close)*0.5ABSProfessionalslope=ABS(slopePro)a0=1a1=5a2=20s0=20s1=40pub=open-close[1]pro=close-openAvepub=average[24](pub)Avepro=average[24](pro)////////////////profe slope //////////////////sum3= (Avepro -Avepro [1])+(Avepro[1] -Avepro [2])+(Avepro[2] -Avepro [3])slopePro =sum3/3if slopePro > slopePro[1] thenPubSlope=1DRAWTEXT("➚",barindex,dis1, Dialog, Standard, 20) COLOURED(255,0,0)endif//////////////publi slope //////////////////slopPub = (Avepub -Avepub [1])if slopePro > slopePro[1] thenProSlope=-1DRAWTEXT("↘",barindex,-dis1, Dialog, Standard, 20) COLOURED(0,0,255)endif//////////////END slope //////////////////a=25pub1=ExponentialAverage(open)- ExponentialAverage (close)[1]pro1=ExponentialAverage (close)- ExponentialAverage (open)publi1=average[a](pub1)profe1=average[a](pro1)b=5pub2=ExponentialAverage(open)- ExponentialAverage (close)[1]pro2=ExponentialAverage (close)- ExponentialAverage (open)publi2=average[b](pub2)*10profe2=average[b](pro2)////////////////profe 1D //////////////////FDpro=profe2-profe2[1]if profe2 > profe2[1] thenDRAWTEXT("U",barindex,dis5, Dialog, Standard, 20) COLOURED(255,0,0)ElsIf profe2 < profe2[1] thenProDecend=-1DRAWTEXT("Dp",barindex,dis4, Dialog, Standard, 20) COLOURED(0,0,225)endif//////////////profe 2D //////////////////SDpro=FDpro-FDpro[1]if FDpro <> 0 and SDpro > 0 thenProCon=-1DRAWTEXT("Vp",barindex,dis2, Dialog, Standard, 20) COLOURED(255,0,0)ElsIf FDpro <> 0 and SDpro < 0 thenDRAWTEXT("A",barindex,dis3, Dialog, Standard, 20) COLOURED(0,0,225)EndIf/////////////END 1D 2D ////////////////////////////////publi 1D //////////////////FD=publi2-publi2[1]FD=publi2-publi2[1]if publi2 > publi2[1] thenDRAWTEXT("U",barindex,-dis4, Dialog, Standard, 20) COLOURED(255,0,0)ElsIf publi2 < publi2[1] thenDRAWTEXT("D",barindex,-dis5, Dialog, Standard, 20) COLOURED(0,0,225)endif//////////////publi 2D //////////////////SD=FD-FD[1]if FD <> 0 and SD > 0 thenDRAWTEXT("V",barindex,-dis2, Dialog, Standard, 20) COLOURED(255,0,0)ElsIf FD <> 0 and SD < 0 thenDRAWTEXT("A",barindex,-dis3, Dialog, Standard, 20) COLOURED(0,0,225)EndIf/////////////END 1D 2D ////////////////////////Condition////////////////if ProDecend=-1 AND ProCon=-1 AND PubSlope=1 AND ProSlope=-1 thenDRAWTEXT("P",barindex,-6, Dialog, Standard, 20) COLOURED(0,0,225) //DRAWARROWup(barindex,-6) COLOURED(0,0,255,fade2)endifDRAWHLINE (0) COLOURED (0, 0,0,100)// rat=0.05*Avepub/Aveproreturn Avepub*a0 as "Pub", Avepro*a0 as "Professional", publi1*40 COLOURED(0, 0, 255) as "Publi1", profe1*20 COLOURED(255, 0, 255) as "Profe1", publi2 COLOURED(0, 0, 255) as "Publi2", profe2*a1 COLOURED(255, 0, 255) as "Profe2", slopPub*s1 COLOURED(0, 0, 255) as "slopPub", slopePro*s0 COLOURED(255, 0, 0) as "slopeAvepro",ABSProfessionalslope*10+5 COLOURED(255, 0, 255) as "ABSproslop" //, rat as "ratio" //COLOURED(255, 0, 0) COLOURED(0, 255, 0),Regarding in the above code, ” if ProDecend=-1 AND ProCon=-1 AND PubSlope=1 AND ProSlope=-1 then ” attached picture
However, is it possible to have advice on how to call previously used if statement condition, please? ”
I do not want the “P” printed everywhere as attached picture…… I only want the P printed only if the above-mentioned 4 conditions are met.
09/28/2021 at 3:57 PM #17866509/28/2021 at 5:13 PM #178668Thank you very much, Rob and Js!! After using “” If FD <> 0 and “” I did it!! It is working.
I hope you didn’t misunderstand but the first derivative must be equal to zero (FD = 0) otherwise you don’t have a maximum or minimum relative value.
When FD <> 0 than all other slopes, except zero, will be true (in practice 99% of the slopes are true when FD <> 0)1 user thanked author for this post.
09/28/2021 at 6:31 PM #178672Yes, you are right. I fixed it accordingly as you say.
//////////////profe 2D //////////////////
SDpro=FDpro-FDpro[1]
RoundFDpro = round(FDpro,1)
if RoundFDpro =0 and SDpro > 0 then
ProCon=-1
DRAWTEXT(“Vp”,barindex,dis2, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf RoundFDpro = 0and SDpro < 0 then
DRAWTEXT(“A”,barindex,dis3, Dialog, Standard, 20) COLOURED(0,0,225)
EndIf
/////////////END 1D 2D ////////////////////////////////publi 1D //////////////////
FDpub=publi2-publi2[1]
if publi2 > publi2[1] then
DRAWTEXT(“U”,barindex,-dis4, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf publi2 < publi2[1] then
DRAWTEXT(“D”,barindex,-dis5, Dialog, Standard, 20) COLOURED(0,0,225)
endif
//////////////publi 2D //////////////////
SD=FDpub-FDpub[1]
RoundFDpub = round(FDpub,1)
if RoundFDpub= 0 and SD > 0 then
DRAWTEXT(“V”,barindex,-dis2, Dialog, Standard, 20) COLOURED(255,0,0)
ElsIf RoundFDpub= 0 and SD < 0 then
DRAWTEXT(“A”,barindex,-dis3, Dialog, Standard, 20) COLOURED(0,0,225)
EndIf
/////////////END 1D 2D //////////////////1 user thanked author for this post.
09/12/2022 at 7:22 AM #200589 -
AuthorPosts
Find exclusive trading pro-tools on