REQUEST TO CODE OPPOSITE DIVERGENCES

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22964 quote
    ALE
    Moderator
    Master

    Hello Guys, Nicolas

    I’m asking to code the following opposite stochastic divergences that could be a long entry signal.

    Thanks in advance

    Ale

    #23234 quote
    Nicolas
    Keymaster
    Master

    Please add a complete example from any instrument with date/hours and stochastic parameters.

    Divergences are sometimes easily spotted with eyes but a quite difficult to get them with code.

    #23271 quote
    ALE
    Moderator
    Master

    Hello Nicolas,
    yes is very difficult..
    I’ve attached another picture hoping to be more clear

    #23293 quote
    Nicolas
    Keymaster
    Master

    Well .. I think it should work for the bullish divergences you are trying to catch.

    But there are of course too many of them with short term period of your stochastic parameters (5,3,3). You should also try to add overbought/oversold level to catch better cases of the stochastic reversal and to avoid whipsaws that the indicator made with its moving average.

    In this code, I use the cross of the stochastic with its moving average to spot reversal and then compare the last 2 different levels with the 2 last prices.

    sto = stochastic[p,k]
    avg = average[d](sto)
    lookback = 20
    
    //bullish divergence
    //first sto cross
    if sto crosses over avg then
    currentsto = sto//[1]
    currentprice = lowest[3](low)
    endif
    
    //previous sto cross
    if barindex<>mybar then
    for i = 1 to lookback do
    if sto[i] crosses over avg[i] then
    previoussto = sto[i]
    previousprice = lowest[i+3](low)
    mybar = barindex[i]
    break
    endif
    next
    endif
    
    //divergence or not?
    if currentsto<previoussto and currentprice>previousprice then
    bulldiv = 1
    else
    bulldiv = 0
    endif
    
    return bulldiv
    #23300 quote
    ALE
    Moderator
    Master

    Hello Nicolas,

    fantastic, its perfect. I need to observe noises to proceed to add filter and other solutions to avoid false positive signals.

    We are studing a scalper strategy based on Stochastic divergences and opposite divergences. We Keep you informed on our progress

    Thanks
    Ale

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

REQUEST TO CODE OPPOSITE DIVERGENCES


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
ALE @aleale Moderator
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/29/2017
Status: Active
Attachments: No files
Logo Logo
Loading...