2nd derivative test for volume

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #178327 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    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:

    ///////////////1st derivative test ///////////////
    
    IF (Volume[2] - Volume[1]) < -1  THEN 
    
    SlopeDecending2=-1                             
    
    IF (Volume[1] - Volume) <  -1    THEN   // the above decending has been contenuaslly going down
    
    SlopeDecending1=-1                              
    
    
    ///////////////2nd derivative test ///////////////
    
    
    IF  (Volume[2] - Volume[1])  <   (Volume[1] - Volume)  THEN
    
    Steepness=-1                               //Sharply falling stringent down
    
    
    ELSE                                             //The above decending is ending soon
    
    Steepness= 1                                //Bearish is ending and recovering to be Bull soon

     

    Reference:

    https://www.khanacademy.org/math/ap-calculus-ab/ab-diff-analytical-applications-new/ab-5-7/v/second-derivative-test

    #178574 quote
    JSJS
    Participant
    Master

    <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.

    FD = Close - Close[n]
    SD = FD - FD[n]
    
    If FD = 0 and SD > 0 then
    Buy x contract at Market
    ElsIf FD = 0 and SD < 0 then
    SellShort x contract at Market
    EndIf
    Suzu Yuk thanked this post
    #178576 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Line 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  ?

    #178580 quote
    JSJS
    Participant
    Master

    Seems 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.

    robertogozzi and Suzu Yuk thanked this post
    #178588 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    It works. Thank you 🙂

    #178663 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    Thank 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.

    Defparam 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=10
    fade2=100
    fade3=200
    
    dis1=1.5
    dis2=2.5
    dis3=3
    dis4=4.5
    dis5=5
    plus1=1
    atr = averagetruerange[10](close)*0.5
    ABSProfessionalslope=ABS(slopePro)
    a0=1
    a1=5
    a2=20
    s0=20
    s1=40
    
    pub=open-close[1]
    pro=close-open
    Avepub=average[24](pub)
    Avepro=average[24](pro)
    
    ////////////////profe slope //////////////////
    sum3= (Avepro -Avepro [1])+(Avepro[1] -Avepro [2])+(Avepro[2] -Avepro [3])
    slopePro =sum3/3
    if slopePro > slopePro[1] then
    PubSlope=1
    DRAWTEXT("➚",barindex,dis1, Dialog, Standard, 20) COLOURED(255,0,0)
    endif
    //////////////publi slope  //////////////////
    slopPub = (Avepub -Avepub [1])
    if slopePro > slopePro[1] then
    ProSlope=-1
    DRAWTEXT("↘",barindex,-dis1, Dialog, Standard, 20) COLOURED(0,0,255)
    endif
    //////////////END  slope  //////////////////
    a=25
    pub1=ExponentialAverage(open)- ExponentialAverage (close)[1]
    pro1=ExponentialAverage (close)- ExponentialAverage (open)
    publi1=average[a](pub1)
    profe1=average[a](pro1)
    
    b=5
    pub2=ExponentialAverage(open)- ExponentialAverage (close)[1]
    pro2=ExponentialAverage (close)- ExponentialAverage (open)
    publi2=average[b](pub2)*10
    profe2=average[b](pro2)
    
    ////////////////profe 1D  //////////////////
    FDpro=profe2-profe2[1]
    if profe2 > profe2[1] then
    DRAWTEXT("U",barindex,dis5, Dialog, Standard, 20) COLOURED(255,0,0)
    ElsIf profe2 < profe2[1] then
    ProDecend=-1
    DRAWTEXT("Dp",barindex,dis4, Dialog, Standard, 20) COLOURED(0,0,225)
    endif
    //////////////profe 2D  //////////////////
    SDpro=FDpro-FDpro[1]
    if FDpro <> 0 and SDpro > 0 then
    ProCon=-1
    DRAWTEXT("Vp",barindex,dis2, Dialog, Standard, 20) COLOURED(255,0,0)
    ElsIf FDpro <> 0 and SDpro < 0 then
    DRAWTEXT("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] 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=FD-FD[1]
    if FD <> 0 and SD > 0 then
    DRAWTEXT("V",barindex,-dis2, Dialog, Standard, 20) COLOURED(255,0,0)
    ElsIf FD <> 0 and SD < 0 then
    DRAWTEXT("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 then
    DRAWTEXT("P",barindex,-6, Dialog, Standard, 20) COLOURED(0,0,225)  //DRAWARROWup(barindex,-6) COLOURED(0,0,255,fade2)
    endif
    
    DRAWHLINE (0) COLOURED (0, 0,0,100)
    // rat=0.05*Avepub/Avepro
    return 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.

    12.png 12.png
    #178665 quote
    Suzu YukSuzu Yuk
    Participant
    Average
    #178668 quote
    JSJS
    Participant
    Master

    Thank 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)

    Suzu Yuk thanked this post
    #178672 quote
    Suzu YukSuzu Yuk
    Participant
    Average

    Yes, 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 //////////////////

    JS thanked this post
    #200589 quote
    KhaledKhaled
    Participant
    Veteran

    Hi Suzu, I’m very interested in this concept. Thank you for sharing. Can you please explain how do you use it? Thanks

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

2nd derivative test for volume


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Suzu Yuk @suzu_yuk Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by KhaledKhaled
4 years ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 09/24/2021
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...