Conversión de Indicator Code

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #233707 quote
    FaisalxFaisalx
    Participant
    New

    Hola, ¿alguien podría ayudarme a convertir este código de indicador para que sea compatible con la plataforma ProRealTime?

     

    // Saty Phase Oscillator
    // Copyright (C) 2022-2024 Saty Mahajan
    // A useful range-based signal to monitor various phases of the market.
    
    //@version=5
    indicator("Saty Phase Oscillator")
    
    // Standard Colors
    green = color.rgb(0,255,0)
    red = color.rgb(255,0,0)
    magenta = color.rgb(255,0,255)
    light_gray = color.rgb(200,200,200)
    gray = color.rgb(150,150,150)
    dark_gray = color.rgb(100,100,100)
    
    // Pivot Data
    pivot = ta.ema(close, 21)
    above_pivot = close >= pivot
    
    // Phases
    extended_up_zone = plot(100.0, color = light_gray, linewidth = 1)
    distribution_zone = plot(61.8, color = gray, linewidth = 1)
    neutral_up_zone = plot(23.6, color = dark_gray, linewidth = 1)
    neutral_down_zone = plot(-23.6, color = dark_gray, linewidth = 1)
    accumulation_zone = plot(-61.8, color = gray, linewidth = 1)
    extended_down_zone = plot(-100.0, color = light_gray, linewidth = 1)
    
    // # Bollinger Band Compression Signal
    bband_offset = 2.0 * ta.stdev(close, 21)
    bband_up = pivot + bband_offset
    bband_down = pivot - bband_offset
    compression_threshold_up = pivot + (2.0 * ta.atr(14))
    compression_threshold_down = pivot - (2.0 * ta.atr(14))
    expansion_threshold_up = pivot + (1.854 * ta.atr(14))
    expansion_threshold_down = pivot - (1.854 * ta.atr(14))
    compression = above_pivot ? (bband_up - compression_threshold_up) : (compression_threshold_down - bband_down)
    in_expansion_zone = above_pivot ? (bband_up - expansion_threshold_up) : (expansion_threshold_down - bband_down)
    expansion = compression[1] <= compression[0]
    compression_tracker = false
    if expansion and in_expansion_zone > 0
        compression_tracker := false
    else if compression <= 0 
        compression_tracker := true
    else 
        compression_tracker := false
    compression_signal = plot(0, color = compression_tracker ? magenta : dark_gray, linewidth = 2)
    
    // # Compressing / Expanding / Expanded
    var tbl = table.new(position.top_right, 1, 1)
    if barstate.islast
        table.cell(tbl, 0, 0, 'Compression', bgcolor = magenta)
    if compression_tracker == false
        table.clear(tbl,0,0,0,0)    
    
    // Saty Phase Oscillator Signal
    raw_signal = ((close - pivot) / (3.0 * ta.atr(14))) * 100
    oscillator = ta.ema(raw_signal, 3)
    phase_oscillator = plot(oscillator, linewidth = 2, color = compression_tracker ? magenta : (oscillator >= 0.0 ? green : red), title = "Phase Oscillator")
    #233742 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Hola. Aquí tienes el código:

    JS thanked this post
    #233757 quote
    jesus1975jesus1975
    Participant
    Veteran

    Salen varios errores en el código

    #233768 quote
    FaisalxFaisalx
    Participant
    New

    muestra un error en el siguiente código
    Aún no confirmo el resto del código.

    expansion=compression[1]<=compression compressionTracker=0 if expansion and inExpansionZone>0 then
    #233779 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Disculpadme. Hubo un problema cuando publiqué y al editar el post parece que el código no se copió correctamente:

     

    //--------------------------------------------------------//
    //PRC_Saty Phase Oscillator
    //version = 0
    //11.06.24
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //--------------------------------------------------------//
    //-----Inputs---------------------------------------------//
    length=21
    multbb=2
    //--------------------------------------------------------//
    //-----Pivot Data-----------------------------------------//
    pivot=average[length,1](close)
    AbovePivot=close>=pivot
    //--------------------------------------------------------//
    //-----Bollinger Band Compression Signal------------------//
    bbandOffset=multbb*STD[length](close)
    bbandUp=pivot+bbandOffset
    bbandDown=pivot-bbandOffset
    compressionThresholdUp=pivot+2*averagetruerange[14]
    compressionThresholdDown=pivot-2*averagetruerange[14]
    expansionThresholdUp=pivot+1.854*averagetruerange[14]
    expansionThresholdDown=pivot-1.854*averagetruerange[14]
    if abovepivot then
    compression=bbandUp-compressionThresholdUp
    inExpansionZone=bbandUp-expansionThresholdUp
    else
    compression=compressionThresholdDown-bbandDown
    inExpansionZone=expansionThresholdDown-bbandDown
    endif
    expansion=compression[1]<=compression
    compressionTracker=0
    if expansion and inExpansionZone>0 then
    compressionTracker=0
    elsif compression<=0 then
    compressionTracker=1
    endif
    //--------------------------------------------------------//
    //-----Phases---------------------------------------------//
    extendedUpZone=100
    distributionZone=61.8
    neutralUpZone=23.6
    neutralDownZone=-23.6
    accumulationZone=-61.8
    extendedDownZone=-100
    //--------------------------------------------------------//
    //-----Saty Phase Oscillator Signal-----------------------//
    rawSignal=(close-pivot)/(3*averagetruerange[14])*100
    oscillator=average[3,1](rawSignal)
    //--------------------------------------------------------//
    //-----Phase Oscillator Colours---------------------------//
    if compressionTracker then
    r=255
    g=0
    b=255
    rs=255
    gs=0
    bs=255
    if islastbarupdate then
    drawtext("Compression",-100,-80)anchor(topRIGHT ,XSHIFT ,YSHIFT )
    drawrectangle(-200,-60,-10,-100)anchor(topRIGHT ,XSHIFT ,YSHIFT )fillcolor(r,g,b,50)
    endif
    else
    if oscillator >=0 then
    r=0
    g=255
    b=0
    else
    r=255
    g=0
    b=0
    endif
    rs=100
    gs=100
    bs=100
    endif
    //--------------------------------------------------------//
    return oscillator as "Phase Oscillator" coloured(r,g,b)style(line,3),extendedUpZone coloured(200,200,200),distributionZone coloured(150,150,150),neutralUpZone coloured(100,100,100),neutralDownZone coloured(100,100,100),accumulationZone coloured(150,150,150),extendedDownZone coloured(200,200,200),0 coloured(rs,gs,bs)style(line,2)
    
    Faisalx thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Conversión de Indicator Code


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
Faisalx @faisalx Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Iván GonzálezIván González
2 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 06/10/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...