Conversion Indic Predictive Ranges from TV to PRT

Forums ProRealTime English forum ProBuilder support Conversion Indic Predictive Ranges from TV to PRT

  • This topic has 3 replies, 2 voices, and was last updated 6 days ago by avatarIván.
Viewing 4 posts - 1 through 4 (of 4 total)
  • #243750
    reb

    Hello to the PRT masters,

    Would you be so kind to adapt the following TradingView code into a PRT code ?

    indicator(“Predictive Ranges [LuxAlgo]”, “LuxAlgo – Predictive Ranges”, overlay = true)
    //——————————————————————————
    //Settings
    //—————————————————————————–{
    length = input.int(200, ‘Length’, minval = 2)
    mult   = input.float(6., ‘Factor’, minval = 0, step = .5)
    tf     = input.timeframe(”, ‘Timeframe’)
    src    = input(close, ‘Source’)
    //—————————————————————————–}
    //Function
    //—————————————————————————–{
    pred_ranges(length, mult)=>
        var avg = src
        var hold_atr = 0.
        atr = nz(ta.atr(length)) * mult
        avg:=src-avg>atr?avg+atr:
          avg-src>atr?avg-atr:
          avg
        hold_atr := avg != avg[1] ? atr / 2 : hold_atr
        [avg + hold_atr * 2, avg + hold_atr, avg, avg – hold_atr, avg – hold_atr * 2]
    //—————————————————————————–}
    //Calculation
    //—————————————————————————–{
    [prR2
      , prR1
      , avg
      , prS1
      , prS2] = request.security(syminfo.tickerid, tf, pred_ranges(length, mult))
    //—————————————————————————–}
    //Plots
    //—————————————————————————–{
    plot_pru2  = plot(prR2, ‘PR Upper 2’, avg != avg[1] ? na : #f23645)
    plot_pru1  = plot(prR1, ‘PR Upper 1’, avg != avg[1] ? na : #f23645)
    plot_pravg = plot(avg , ‘PR Average’, avg != avg[1] ? na : #5b9cf6)
    plot_prl1  = plot(prS1, ‘PR Lower 1’, avg != avg[1] ? na : #089981)
    plot_prl2  = plot(prS2, ‘PR Lower 2’, avg != avg[1] ? na : #089981)
    //Fills
    fill(plot_pru2, plot_pru1, avg != avg[1] ? na : color.new(#f23645, 95))
    fill(plot_prl1, plot_prl2, avg != avg[1] ? na : color.new(#089981, 95))
    //—————————————————————————–}
    Thanks in advance,
    Reb
    #243762

    Hi. Here you have the code:

    #243819
    reb

    Hi Ivan

    Well done, nice job

    I have a discrepancy between  range size in PRT and those in TV, do you know why ? (see attached)

     

    Thks in  advance

     

    Reb

    #243842

    Hi. I don't know. It could be because the prices are not the same (dividend adjustment, due to the data source itself, …)

Viewing 4 posts - 1 through 4 (of 4 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login