Conversion of simple bar color indicator from Pinescript to Pro Builder

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #202669 quote
    Philip1212
    Participant
    New

    Hi all,

    In Trading View, I had coloured my bars depending on the close of the bar. In Pinescipt V5, the code looked like this:

     

    indicator(“Bar Color”, overlay=true)

     

    //Bull bar 1/4

    data1 = close > ((high – low) * 0.75) + low

    barcolor(close > ((high – low) * 0.75) + low ? #27af40 : na)

     

    //Bull bar 1/3

    data2 = close > ((high – low) * 0.666) + low and close < ((high – low) * 0.75) + low

    barcolor(close > ((high – low) * 0.666) + low and close < ((high – low) * 0.75) + low? #24532d : na)

     

    //Neutral Bull bar

    data3 = close < (((high – low) * 0.666) + low) and  close > (high – ((high – low) * 0.666)) and close > open

    barcolor(close < (((high – low) * 0.666) + low) and  close > (high – ((high – low) * 0.666)) and close > open? #a5dfb2 : na)

     

    If anyone here can help me convert this code to ProBuilder I would be very grateful.

    Philip

    #202683 quote
    Nicolas
    Keymaster
    Master

    Here is the translated code that color the candlestick accordingly to the conditions. If conditions are not met, then the bar color is the default one of the platform.

    //Bull bar 1/4
    data1 = close > ((high - low) * 0.75) + low
    //Bull bar 1/3
    data2 = close > ((high - low) * 0.666) + low and close < ((high - low) * 0.75) + low
    //Neutral Bull bar
    data3 = close < (((high - low) * 0.666) + low) and  close > (high - ((high - low) * 0.666)) and close > open
    if data1 then 
    r=39
    g=175
    b=64
    elsif data2 then 
    r=36
    g=83
    b=45
    elsif data3 then 
    r=165
    g=223
    b=178
    endif 
    if data1+data2+data3>0 then 
    drawcandle(open,high,low,close) coloured(r,g,b)
    endif 
    
    return
    #202697 quote
    Philip1212
    Participant
    New

    Thank you for the quick response! It works perfectly.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Conversion of simple bar color indicator from Pinescript to Pro Builder


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Philip1212 @philip1212 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Philip1212
3 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/17/2022
Status: Active
Attachments: No files
Logo Logo
Loading...