Andean Oscilator conversion

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #199240 quote
    Sofitech
    Participant
    Master

    Bonjour Nicolas, Bonjour à tous.
    J’ai découvert il y a quelques semaines un oscillateur que je trouve simple et utile sur tradingview. Le code ne semble pas compliqué mais je suis bien incapable de le convertir en language PRT.
    Peut-être que l’équivalent ou presque existe déjà.
    Est-ce que quelqu’un serait en mesure de convertir ce code. Je fais figurer une image pour l’illustrer. La ligne verte peut être interprétée comme une force acheteuse, la rouge une force vendeuse, la jaune une ligne “signal”

    // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
    // © alexgrover
    
    //Original post : Alpaca.markets/learn/andean-oscillator-a-new-technical-indicator-based-on-an-online-algorithm-for-trend-analysis/
    
    //@version=5
    indicator("Andean Oscillator")
    //------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length     = input(50)
    
    sig_length = input(9,'Signal Length')
    
    //-----------------------------------------------------------------------------}
    //Exponential Envelopes
    //-----------------------------------------------------------------------------{
    var alpha = 2/(length+1)
    
    var up1 = 0.,var up2 = 0.
    var dn1 = 0.,var dn2 = 0.
    
    C = close
    O = open
    
    up1 := nz(math.max(C, O, up1[1] - (up1[1] - C) * alpha), C)
    up2 := nz(math.max(C * C, O * O, up2[1] - (up2[1] - C * C) * alpha), C * C)
    
    dn1 := nz(math.min(C, O, dn1[1] + (C - dn1[1]) * alpha), C)
    dn2 := nz(math.min(C * C, O * O, dn2[1] + (C * C - dn2[1]) * alpha), C * C)
    
    //Components
    bull = math.sqrt(dn2 - dn1 * dn1)
    bear = math.sqrt(up2 - up1 * up1)
    
    signal = ta.ema(math.max(bull, bear), sig_length)
    
    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    plot(bull, 'Bullish Component', #089981)
    
    plot(bear, 'Bearish Component', #f23645)
    
    plot(signal, 'Signal', #ff9800)
    
    //-----------------------------------------------------------------------------}
    #199247 quote
    JC_Bywan
    Moderator
    Master

    Bonjour, tentative de conversion à tester, en attendant que Nicolas, bien plus habitué à faire les conversions, passe par ce post et valide ou corrige:

    // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
    // © alexgrover
    //Original post : Alpaca.markets/learn/andean-oscillator-a-new-technical-indicator-based-on-an-online-algorithm-for-trend-analysis/
    //@version=5
    //indicator("Andean Oscillator")
    
    // Converted from pinescript for ProRealTime
    // 19.08.2022
    // JC_Bywan @ www.ProRealCode.com
    // Sharing ProRealTime knowledge
    
    //------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length=50
    siglength = 9
    
    //-----------------------------------------------------------------------------}
    //Exponential Envelopes
    //-----------------------------------------------------------------------------{
    alpha = 2/(length+1)
    
    //up1 = 0
    //up2 = 0
    //dn1 = 0
    //dn2 = 0
    C = close
    O = open
    
    if barindex=0 then
    up1 = C
    up2 = C * C
    dn1 = C
    dn2 = C * C
    else
    up1 = max(max(C, O), up1[1] - (up1[1] - C) * alpha)
    up2 = max(max(C * C, O * O), up2[1] - (up2[1] - C * C) * alpha)
    dn1 = min(min(C, O), dn1[1] + (C - dn1[1]) * alpha)
    dn2 = min(min(C * C, O * O), dn2[1] + (C * C - dn2[1]) * alpha)
    endif
    //Components
    bull = sqrt(dn2 - dn1 * dn1)
    bear = sqrt(up2 - up1 * up1)
    
    maxi = max(bull, bear)
    signal = ExponentialAverage[siglength](maxi)
    
    return bull as "Bullish Component" coloured(8,153,129), bear as "Bearish Component" coloured(242,54,69), signal as "Signal" coloured(255,152,0)
    Sofitech and Nicolas thanked this post
    #199254 quote
    Nicolas
    Keymaster
    Master

    ça me semble correct à la lecture, merci noobywan.

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

Andean Oscilator conversion


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Sofitech @sofitech Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Nicolas
3 years, 5 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 08/19/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...