Programming divergence of stochastic

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #18306 quote
    kg6450
    Participant
    Average

    Hi all, I was hoping that someone would be able to help me program a divergence in price and stochastic indicator.

    What I am looking to test for is a lower high in price compared to a previous high, while the stochastic indicator shows a lower high compared to the previous high?

    Has anyone coded something like this before?

    #18544 quote
    Nicolas
    Keymaster
    Master

    Please find attached the indicator code for stochastic divergences. The indicator spot divergences between price and the crossover of the stochastic with its own moving average signal line.

    The stochastic values are only taken into account if they are above the overbought zone or below the oversold zone (you can modify these levels at will in the parameters).

    This is the same code as the ones from the MACD or RSI divergences indicators already posted into the Library in other different format:

    #18581 quote
    supertiti
    Participant
    Master

    Bonjour Nicolas,
    Je rajoute cette ligne pour identifier de quelle divergence (bull) on parle mais le retour image n’est pas top ! d’où vient mon erreur STP

    DRAWTEXT ( "O " ,barindex,0.20,dialog,standard,20) coloured ( 0,153,0 )
    DRAWTEXT ( "T " ,barindex,0.30,dialog,standard,20) coloured ( 0,153,0 )
    DRAWTEXT ( "S " ,barindex,0.40,dialog,standard,20) coloured ( 0,153,0 )
    #18584 quote
    Nicolas
    Keymaster
    Master

    @Supertiti

    Merci de parler en Anglais dans le forum Anglais.

    Please speak English in English Forums!!

    #18585 quote
    supertiti
    Participant
    Master

    Hello Nicolas,

    I add this line to identify what divergence (bull) we talk about but the image return is not top! Where  my error comes from

    #18596 quote
    supertiti
    Participant
    Master
    Why the bull histogramm don't match !!??
    
    
    // DIVERGENCES STO PRC adapted from HK-LISSE code
    
    
    x = stochastic[p,k]
    y = average[d](x)
    
    
    if x>overboughtzone then
    hi=max(hi,x)
    hico=max(hico,max(high,high[1]))
    endif
    if x crosses under y then
    sto2b=sto1b
    sto1b=hi
    hi=0
    p3b=p1b
    p2b=max(p1b,hico1)
    p1b=max(highest[3](high),hico)
    if p2b=p1b then
    p2b=max(p3b,p4b)
    endif
    hico=0
    hico1=0
    endif
    if x<y then
    p4b=hico1
    hico1=max(hico1,high)
    endif
    if p1b>p2b and sto1b<sto2b and x crosses under y and x<x[1] then
    signB= -2
    else
    signB= 0
    endif
    
    if x<oversoldzone then
    lo=min(lo,x)
    lowco=min(lowco,min(low,low[1]))
    endif
    if x CROSSES OVER y  then
    sto2h=sto1h
    sto1h=lo
    lo=100
    p3h=p1h
    p2h=min(p1h,lowco1)
    p1h=min(lowest[3](low),lowco)
    if p2h=p1h then
    p2h=min(p3h,p4h)
    endif
    lowco=100000
    lowco1=100000
    endif
    if x>y then
    p4h=lowco1
    lowco1=min(lowco1,low)
    endif
    if p1h<p2h and sto1h > sto2h and x crosses over y and x>x[1]  then
    signH= 2
    else
    signH= 0
    endif
    ////////////////////////////////////////////////
    If signB CROSSES UNDER 0 then
    DRAWTEXT ( "S " ,barindex,- 0.20,dialog,standard,20) coloured ( 255,0,127 )
    DRAWTEXT ( "T " ,barindex,- 0.30,dialog,standard,20) coloured ( 255,0,127 )
    DRAWTEXT ( "O " ,barindex,- 0.40,dialog,standard,20) coloured ( 255,0,127 )
    endif
    
    If signH CROSSES OVER  0 then
    DRAWTEXT ( "O " ,barindex,0.20,dialog,standard,20) coloured ( 0,153,0 )
    DRAWTEXT ( "T " ,barindex,0.30,dialog,standard,20) coloured ( 0,153,0 )
    DRAWTEXT ( "S " ,barindex,0.40,dialog,standard,20) coloured ( 0,153,0 )
    endif
    
    return     signH as " div STO bull ", signB as " div STO bear " , 0 as " zero "
    
    
    // Variables :
    // p = 14
    // Overboughzone = 80
    // Oversellzone = 20
    // K = 3
    // D = 6
    #18608 quote
    supertiti
    Participant
    Master

    OK

    If signB < 0 then
    DRAWTEXT ( "S " ,barindex,- 0.20,dialog,standard,20) coloured ( 255,0,127 )
    DRAWTEXT ( "T " ,barindex,- 0.30,dialog,standard,20) coloured ( 255,0,127 )
    DRAWTEXT ( "O " ,barindex,- 0.40,dialog,standard,20) coloured ( 255,0,127 )
    endif
    
    If signH > 0 then
    DRAWTEXT ( "O " ,barindex,0.20,dialog,standard,20) coloured ( 0,153,0 )
    DRAWTEXT ( "T " ,barindex,0.30,dialog,standard,20) coloured ( 0,153,0 )
    DRAWTEXT ( "S " ,barindex,0.40,dialog,standard,20) coloured ( 0,153,0 )
    endif
    #19060 quote
    kg6450
    Participant
    Average

    Hi Nicholas sorry for not responding, I’ve been away for a while.

    Thanks for the link I will have a go with those!

    #52700 quote
    pieroim
    Participant
    Average

    Hi, I want reduce the false signal on the stochastic divergence by considering true signals only that signals generated when the stochastic remain under the oversold zone or above the overbought zone.

    In the attached picture you can see that the code doesn’t work correctly.. you can see the code too, but I don’t understand why.. Nicolas can you help me?

    Thanks

    Piero

    #52802 quote
    Nicolas
    Keymaster
    Master

    This is already what the code does (if I remember correctly), you have to define yourself the level of the “oversoldzone” and also for “overboughtzone” in the code.

    #52806 quote
    pieroim
    Participant
    Average

    No Nicolas, see the pictures..

    ————————————–

    Another question, from yesterday I have a mistake from the Proscreener web area when I go to write a new post, this is the post:

    Title: Is there a way to do a screening of the only last “x” bars?

    I’m working on a stochastic divergence screening routine, but it give me all the signals that it find in the period that it go to analyze (I don’t know how long is the period), is there a way to retrieve only the signals that it find in the last fixed number of bars?

    Barindex can work in the proscreening?

    Thank’s

    Piero

    #52812 quote
    pieroim
    Participant
    Average

    This is another mistake that the indicator gives:

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

Programming divergence of stochastic


ProOrder support

New Reply
Author
author-avatar
kg6450 @kg6450 Participant
Summary

This topic contains 11 replies,
has 4 voices, and was last updated by pieroim
8 years, 2 months ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 12/12/2016
Status: Active
Attachments: 10 files
Logo Logo
Loading...