How can I prevent overwriting of existing values?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #248173 quote
    Florian878
    Participant
    New

    Hi all,

    recently I was converting an indicator from Tradingview to ProBuilder.
    The thing, I can’t get solved is:

    When a new candles forms, the previous calculated value of the indicator is still visible while the newer one overlays/overwrites the previous value.

    I tried to fix this with if

    islastbarupdate then
    drawtext(value, x, y) …
    endif

    Does anyone have any ideas how to solve this?

    See pic. attached.

    Thank you so much in advance.

    Best regards,
    Florian

    #248175 quote
    JS
    Participant
    Senior

    Hi Florian,

    Have you tried this instruction at the beginning of your code…?

    DefParam DrawOnLastBarOnly=True

    robertogozzi, Florian878 and Iván González thanked this post
    #248179 quote
    Florian878
    Participant
    New
    Hi JS, First of all: Thank you for your fast response. Yes, I tried this but as I also have a condition to color my candles it won’t work as I intended to. It would then limit the colored candles to the current one instead of all of them. If there is a work around to still have all candles colored, please let me know. Thanks, Florian
    #248183 quote
    JS
    Participant
    Senior

    What you can try is to split your indicator into two parts, one part for coloring your candles (without “DrawOnLastBarOnly”) and one for the text using DrawOnLastBarOnly…

    Florian878 and Iván González thanked this post
    #248188 quote
    Florian878
    Participant
    New

    Yeah, I already thought about that. Thanks for the reminder. So there is no other way around to solve this issue? Honestly I’m not a huge fan of having a bunch of indicators on my chart.

    #248189 quote
    Iván González
    Moderator
    Master
    There is a way… You could store variables in arrays and then use a loop. here you have an example:
    defparam drawonlastbaronly=true
    
    prd = 20
    src1 = low
    //pivots low
    if src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then
    $pivotlowy[z+1] = src1[prd]
    $pivotlowx[z+1] = barindex[prd]
    z = z + 1
    endif
    if islastbarupdate then
    for i=z downto 0 do
    drawpoint($pivotlowx[i],$pivotlowy[i],3)coloured("red")
    next
    endif
    
    return 
    Florian878 thanked this post
    #248395 quote
    Florian878
    Participant
    New
    Thank you, Iván, I’ll give it a try. Sounds plausible to me. greetz, Florian
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

How can I prevent overwriting of existing values?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Florian878 @florian878 Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by Florian878
7 months, 3 weeks ago.

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