Painting bars by ATR and VOLUME

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #231172 quote
    efahmyefahmy
    Participant
    Average
    I need a code for the indicator, using the following functions and variables: ATR: The Average True Range function calculates the true range of the price over a specified period. Volume: The Volume function returns the total volume traded over a specified period. Average Volume: You’ll need to calculate the average volume over a certain period, such as 14 days. Price: The current price of the security. Conditions: Create logical conditions based on your requirements. Color: Set the color of the bar based on the conditions met.   The logic for the conditions would be as follows:   if ATR > 2 * ATR[14] and Volume > AverageVolume and Price > Price[1]: Color = “DarkGreen” elif ATR > 2 * ATR[14] and Volume > AverageVolume and Price < Price[1]: Color = “DarkRed” else: Color = “DefaultColor”
    #231173 quote
    JSJS
    Participant
    Master
    Hi, Try this one:  
    //ATRPeriod=5
    //AvgATRPeriod=14
    //AvgVolPeriod=14
    
    xATR=AverageTrueRange[ATRPeriod](Close)
    xAvgATR=Average[AvgATRPeriod](xATR)
    xAvgVol=Average[AvgVolPeriod](Volume)
    xVol=Volume
    xPrice=Close
    
    C1=xATR>2*xAvgATR
    C2=xVol>xAvgVol
    C3=xPrice>xPrice[1]
    C4=xPrice<xPrice[1]
    
    If C1 and C2 and C3 then
    DrawCandle(Open,High,Low,Close)Coloured("DarkGreen")
    ElsIf C1 and C2 and C4 then
    DrawCandle(Open,High,Low,Close)Coloured("DarkRed")
    Else
    DrawCandle(Open,High,Low,Close)Coloured("DarkBlue")
    EndIf
    
    Return //xATR as "ATR",xAvgAtr as "AvgATR",xAvgVol as "AvgVol",xVol as "Volume",xPrice as "Price"
    Scherm­afbeelding-2024-04-07-om-03.24.33.png Scherm­afbeelding-2024-04-07-om-03.24.33.png Painting-Bars-with-ATRVol.itf
    #231176 quote
    efahmyefahmy
    Participant
    Average
    Many thanks mate, but can I change the other bars to light gray instead of dark blue using “lightgray”
    #231178 quote
    JSJS
    Participant
    Master

    If the “other bars” need to be light grey, you can replace “DarkBlue” with “LightGrey”… (or just “Grey” as shown in the screenshot)

    DrawCandle(Open,High,Low,Close)Coloured(“LightGrey”)

    Scherm­afbeelding-2024-04-07-om-09.48.31.png Scherm­afbeelding-2024-04-07-om-09.48.31.png
    #231195 quote
    efahmyefahmy
    Participant
    Average
    Many thanks mate,
    JS 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

Painting bars by ATR and VOLUME


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
efahmy @efahmy Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by efahmyefahmy
2 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/07/2024
Status: Active
Attachments: 3 files
ProRealCode ProRealCode
Loading...