CYCLE SWING MOMENTUM

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #228521 quote
    deletedaccount22102025
    Participant
    New

    Hola a tod@s. Puede alguien transcribir el siguiente indicador de Tradingview a PRT?:

    https://es.tradingview.com/v/b7o7GmWT/

    Cycle1(i, waveThrottle, cycs) =>
        ret = 6.0*waveThrottle+1.0
        if (i==0)
            ret := 1.0+waveThrottle
        else if (i==1)
            ret := 1.0+waveThrottle*5.0
        else if (i==(cycs-1))
            ret := 1.0+waveThrottle
        else if (i==(cycs-2))
            ret := 1.0+waveThrottle*5.0
        ret
    Cycle2(i, waveThrottle, cycs) =>
        ret=-4.0*waveThrottle
        if (i==0)
            ret := -2.0*waveThrottle
        else if (i==(cycs-1))
            ret := 0.0
        else if (i==(cycs-2))
            ret := -2.0*waveThrottle
        ret
    Cycle3(i, waveThrottle, cycs) =>
        ret = waveThrottle
        if (i==(cycs-1))
            ret := 0.0
        else if (i==(cycs-2))
            ret := 0.0
        ret
    iWTT_CSI_processor(CycleCount) =>
        wtt1=0.0
        wtt2=0.0
        wtt3=0.0
        wtt4=0.0
        wtt5=0.0
        _wtt1=0.0
        _wtt2=0.0
        _wtt3=0.0
        _wtt4=0.0
        _wtt5=0.0
        momentum=0.0
        acceleration=0.0
        swing=0.0
        cycs=50
        waveThrottle=float(160*CycleCount)
        currentVal=0.0
        for i = 0 to cycs – 1 by 1
            swing:=Cycle1(i,waveThrottle,cycs)-wtt4*wtt1-_wtt5*_wtt2
            if(swing==0)
                break
            momentum := Cycle2(i,waveThrottle,cycs)
            _wtt1 := wtt1
            wtt1 := (momentum-wtt4*wtt2)/swing
            acceleration:=Cycle3(i,waveThrottle,cycs)
            _wtt2 := wtt2
            wtt2 := acceleration/swing
            currentVal:=(close[49-i]-_wtt3*_wtt5-wtt3*wtt4)/swing
            _wtt3  := wtt3
            wtt3   := currentVal
            wtt4   := momentum-wtt5*_wtt1
            _wtt5  := wtt5
            wtt5   := acceleration
        currentVal
    banding(CRSI, Period, Leveling) =>
        var percent = Leveling / 100.0
        periodMinusOne = Period-1
        maxima = -999999.0
        minima =  999999.0
        for i=0 to periodMinusOne
            crsi = nz(CRSI[i])
            if      crsi > maxima
                maxima := crsi
            else if crsi < minima
                minima := crsi
        stepFactor = (maxima – minima) / 100.0
        float lowBand = na
        for steps=0 to 100
            testValue = minima + stepFactor * steps
            below = 0
            for m=0 to periodMinusOne
                if CRSI[m] < testValue
                    below := below + 1
            if below/Period >= percent
                lowBand := testValue
                break
        float highBand = na
        for steps=0 to 100
            testValue = maxima – stepFactor * steps
            above = 0
            for m=0 to periodMinusOne
                if CRSI[m] >= testValue
                    above := above + 1
            if above/Period >= percent
                highBand := testValue
                break
        [highBand, lowBand]
    //==== Vars
    var leveling  = 10
    var cyclicMemory = 34
    //===== Calculations
    thrust1=iWTT_CSI_processor(1)
    thrust2=iWTT_CSI_processor(10)
    CSIBuffer = thrust1-thrust2
    [highBand, lowBand] = banding( CSIBuffer, cyclicMemory,  leveling)
    highband = plot(highBand, “HighBand”, color=color.aqua , editable=false)
    lowband  = plot( lowBand,  “LowBand”, color=color.aqua , editable=false)
    fill( highband,  lowband, transp=90 , color=#CCCC77   )
    plot(0, color=color.black, linewidth=1, transp=25)
    plot(CSIBuffer, color=color.fuchsia, linewidth=1)
    #233750 quote
    Iván González
    Moderator
    Master

    Buenas! Aquí tienes el indicador.

    Queda pendiente el módulo de divergencias. Con tanto bucle se hace muy lento el indicador…

    //------------------------------------------------------------//
    //PRC_Cycle swing momentum
    //version = 0
    //11.06.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //------------------------------------------------------------//
    //-----Inputs-------------------------------------------------//
    leveling = 10
    cyclicmemory = 34
    //------------------------------------------------------------//
    //-----Thrust1 Calculation------------------------------------//
    CycleCount = 1
    wtt1=0.0
    wtt2=0.0
    wtt3=0.0
    wtt4=0.0
    wtt5=0.0
    pwtt1=0.0
    pwtt2=0.0
    pwtt3=0.0
    pwtt4=0.0
    pwtt5=0.0
    mom=0.0
    acceleration=0.0
    swing=0.0
    cycs=50
    waveThrottle=(160*CycleCount)
    currentVal=0.0
    ret1=0
    ret2=0
    ret3=0
    for i = 0 to cycs - 1 do
    
    //Cycle1(i,waveThrottle,cycs)
    ret1 = 6.0*waveThrottle+1.0
    if i = 0 then
    ret1 = 1+waveThrottle
    elsif i=1 then
    ret1 = 1+waveThrottle*5
    elsif i=cycs-1 then
    ret1 = 1+waveThrottle
    elsif i=cycs-2 then
    ret1 = 1+waveThrottle*5
    endif
    swing = ret1-wtt4*wtt1-pwtt5*pwtt2
    if swing = 0 then
    break
    endif
    
    //Cycle2(i, waveThrottle, cycs)
    ret2 = -4.0*waveThrottle
    if i=0 then
    ret2 = -2.0*waveThrottle
    elsif i=(cycs-1)then
    ret2 = 0.0
    elsif i=(cycs-2) then
    ret2 = -2.0*waveThrottle
    endif
    mom=ret2
    
    pwtt1=wtt1
    wtt1=(mom-wtt4*wtt2)/swing
    
    //Cycle3(i, waveThrottle, cycs)
    ret3 = waveThrottle
    if i=cycs-1 then
    ret3 = 0
    elsif i=cycs-2 then
    ret3 = 0
    endif
    
    acceleration=ret3
    pwtt2=wtt2
    wtt2=acceleration/swing
    
    currentval = (close[49-i]-pwtt3*pwtt5-wtt3*wtt4)/swing
    pwtt3=wtt3
    wtt3=currentval
    wtt4=mom-wtt5*pwtt1
    pwtt5=wtt5
    wtt5=acceleration
    next
    
    thrust1 = currentval
    
    /////thrust2
    CycleCount2 = 10
    wtt12=0.0
    wtt22=0.0
    wtt32=0.0
    wtt42=0.0
    wtt52=0.0
    pwtt12=0.0
    pwtt22=0.0
    pwtt32=0.0
    pwtt42=0.0
    pwtt52=0.0
    mom2=0.0
    acceleration2=0.0
    swing2=0.0
    cycs2=50
    waveThrottle2=(160*CycleCount2)
    currentVal2=0.0
    
    for j = 0 to cycs2 - 1 do
    //Cycle1(i,waveThrottle,cycs)
    ret12 = 6.0*waveThrottle2+1.0
    if j = 0 then
    ret12 = 1+waveThrottle2
    elsif j=1 then
    ret12 = 1+waveThrottle2*5
    elsif j=cycs2-1 then
    ret12 = 1+waveThrottle2
    elsif j=cycs2-2 then
    ret12 = 1+waveThrottle2*5
    endif
    swing2 = ret12-wtt42*wtt12-pwtt52*pwtt22
    if swing2 =0 then
    break
    endif
    //Cycle2(i, waveThrottle, cycs)
    ret22 = -4.0*waveThrottle2
    if j=0 then
    ret22 = -2.0*waveThrottle2
    elsif j=(cycs2-1)then
    ret22 = 0.0
    elsif j=(cycs2-2) then
    ret22 = -2.0*waveThrottle2
    endif
    mom2=ret22
    pwtt12=wtt12
    wtt12=(mom2-wtt42*wtt22)/swing2
    
    //Cycle3(i, waveThrottle, cycs)
    ret32 = waveThrottle2
    if j=cycs2-1 then
    ret32 = 0
    elsif j=cycs2-2 then
    ret32 = 0
    endif
    
    acceleration2=ret32
    pwtt22=wtt22
    wtt22=acceleration2/swing2
    
    currentval2 = (close[49-j]-pwtt32*pwtt52-wtt32*wtt42)/swing2
    pwtt32=wtt32
    wtt32=currentval2
    wtt42=mom2-wtt52*pwtt12
    pwtt52=wtt52
    wtt52=acceleration2
    next
    
    thrust2=currentval2
    
    CSIBuffer = thrust1-thrust2
    
    //banding(CRSI, Period, Leveling)
    //banding(CSIBuffer,cyclicMemory,leveling)
    CRSI=CSIBuffer
    Period=cyclicMemory
    percent = leveling/100
    periodMinusone = period-1
    maxima = -999999.0
    minima =  999999.0
    for i=0 to periodMinusone do
    //crsi = crsi[i]
    if crsi[i] > maxima then
    maxima = crsi[i]
    elsif crsi[i] < minima then
    minima = crsi[i]
    endif
    next
    stepfactor = (maxima-minima)/100
    lowband = 0
    for steps=0 to 100 do
    testvalue = minima+stepfactor*steps
    below=0
    for m=0 to periodMinusone do
    if crsi[m]<testvalue then
    below=below+1
    endif
    next
    if below/period >= percent then
    lowband = testvalue
    break
    endif
    next
    highband=0
    for steps=0 to 100 do
    testvalue=maxima-stepfactor*steps
    above=0
    for m=0 to periodMinusone do
    if crsi[m]>=testvalue then
    above=above+1
    endif
    next
    if above/Period >= percent then
    highband=testvalue
    break
    endif
    next
    colorbetween(highband,lowband,204,204,119,90)
    
    return CSIBuffer as "CSIBuffer" coloured(224,64,251)style(line,2), Lowband as "Lowband" coloured(0,188,212),highband as "Highband" coloured(0,188,212), 0 coloured("black")
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

CYCLE SWING MOMENTUM


ProBuilder: Indicadores y Herramientas

New Reply
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
1 year, 8 months ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 02/21/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...