How to change the colour of a base candle (body less than 50% of the range)?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #217460 quote
    anilkc
    Participant
    New

    On my chart, all the candles are either shown in green or red. I want to distinguish the base candles (body less than 50% of the range) with a different colour. How can I do this in ProRealTime? I’m using version 1.1-1.8.0_202.

    #217462 quote
    anilkc
    Participant
    New

    Here is the code I wrote to draw the base candle in yellow but I get an error message.

    // Define variables
    vars:
    Range(0), // Range of the candle
    BodySize(0), // Size of the candle body
    CandleColor(black); // Color of the candle (default)

    // Calculate the range and body size
    Range = high – low;
    BodySize = abs(open – close);

    // Check if the body is less than 50% of the range
    if BodySize < (Range * 0.5) then
    CandleColor = yellow; // Change the color to yellow for the base candle

    // Set the candle color
    PlotColor(1, CandleColor);

    #217471 quote
    JS
    Participant
    Senior

    Hi @anilkc

    Try this one…

     

     

    // Calculate the range and body size
    xRange = Range
    xBodySize = abs(open - close)
    
    // Check if the body is less than 50% of the range
    if xBodySize < (xRange * 0.5) then
    DrawCandle(Open,High,Low,Close)Coloured("Yellow") // Change the color to yellow for the base candle
    EndIf
    
    Return
    Scherm­afbeelding-2023-07-09-om-18.42.53.png Scherm­afbeelding-2023-07-09-om-18.42.53.png
    #217473 quote
    anilkc
    Participant
    New

    This is great. Thank you so much. It works perfectly.

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

How to change the colour of a base candle (body less than 50% of the range)?


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
anilkc @anilkc Participant
Summary

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

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 07/09/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...