Klinger Oscillator conversion

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #243195 quote
    regus
    Participant
    Veteran

    Is it possible to convert this Thinkscript code to Prorealcode.

    input MALength = 13;

    def DM = high – low;
    def Trend = if hlc3 > hlc3[1] then 1 else -1;
    def CM = DM + if Trend == Trend[1] then CM[1] else DM[1];
    def VForce = if CM != 0 then Trend * 100 * volume * AbsValue(2 * DM / CM – 1) else VForce[1];
    plot KVOsc = ExpAverage(VForce, 34) – ExpAverage(VForce, 55);
    plot TriggerLine = Average(KVOsc, MALength);
    plot ZeroLine = 0;Klin

    #243201 quote
    cjr30
    Participant
    Master

    No se si estará bien, pero creo que es de la siguiente forma:

    I don’t know if it’s correct, but I think it’s like this:

    MALength = 13
    DM = high – low
    hlc3= (high + low + close)/3
    if(hlc3>hlc3[1]) THEN
    Trend = 1
    ELSE
    Trend = -1
    ENDIF
    CM = DM
    if Trend = Trend[1] then
    CM = CM[1] + DM
    else
    CM = DM[1]
    endif

    if CM <> 0 then
    VForce = Trend * 100 * volume * Abs(2 * DM / CM – 1)
    else
    VForce = VForce[1]
    endif
    KVOsc = ExponentialAverage[34](VForce) – ExponentialAverage[55](VForce)
    TriggerLine = Average[MALength](KVOsc)
    return KVOsc as “Klinger” ,TriggerLine as “Signal”

    #243203 quote
    robertogozzi
    Moderator
    Master

    @cjr30

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums

    Thanks 🙂

    #243206 quote
    JS
    Participant
    Senior

    Here is the modified version:

    // Define input parameter
    MALength = 13
    HLC3=(High+Low+Close)/3
    
    // Calculate DM (Daily Movement)
    DM = HIGH - LOW
    
    // Determine Trend
    IF (HLC3 > HLC3[1]) THEN
    Trend = 1
    ELSE
    Trend = -1
    ENDIF
    
    // Calculate CM (Cumulative Movement)
    IF (Trend = Trend[1]) THEN
    CM = DM + CM[1]
    ELSE
    CM = DM + DM[1]
    ENDIF
    
    // Calculate VForce (Volume Force)
    IF (CM <> 0) THEN
    VForce = Trend * 100 * Volume * abs(2 * DM / CM - 1)
    ELSE
    VForce = VForce[1]
    ENDIF
    
    // Calculate KVOscillator (KVOsc)
    KVOsc = Average[34,1](VForce) - Average[55,1](VForce)
    
    // Calculate Trigger Line (Signal Line)
    TriggerLine = Average[MALength](KVOsc)
    
    // Define Zero Line
    ZeroLine = 0
    
    // Plot the indicators
    RETURN KVOsc AS "KVOsc" Coloured("Yellow"), TriggerLine AS "TriggerLine" Coloured("Green"), ZeroLine AS "ZeroLine"

    regus thanked this post
    #243208 quote
    regus
    Participant
    Veteran
    Thanks for your try cjr30. If I compare both codes with same timeframe there is huge difference (yes it could be data). Can someone else give it a try?
    #243218 quote
    Iván González
    Moderator
    Master
    Hi, I've coded it too, I hadn't seen the JS code and I have the same result as him.
    MaLength=13
    
    dm=high-low
    hlc3=(high+low+close)/3
    
    if hlc3 > hlc3[1] then
    trend=1
    else
    trend=-1
    endif
    
    if trend=trend[1] then
    cm=dm+cm[1]
    else
    cm=dm+dm[1]
    endif
    
    if cm<>0 then
    vForce=trend*100*volume*abs(2*dm/cm-1)
    else
    vForce=vForce[1]
    endif
    
    KVosc=average[34,1](vForce)-average[55,1](vForce)
    triggerline=average[MaLength](KVosc)
    zero=0
    return KVosc coloured("blue"), triggerline coloured("red"), zero
    regus thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Klinger Oscillator conversion


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
regus @regus Participant
Summary

This topic contains 5 replies,
has 5 voices, and was last updated by Iván González
1 year ago.

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