Change arrow color in realtime according to a condition

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

    Dear,

    I would like to build my own indicator that uses the “islastbarupdate” to draw an arrow (upward or downward) according to the trend during the creating of the last candle. In addition to that I would like to change the color of that arrow during the last bar in this way:

    when the new bar open and the price stays above the closing of the previous one the arrow is yellow, after having the yellow arrow (and only after having this first condition satisied) if the price goes below the close of the previous one the arrow shall become red.

    Is it possible? I try different way but without success, I’m not able to control the sequence with the flag variable

    flag=0
    
    if islastbarupdate then
     
    while (low >= close[1]-1 and close[1]>open[1] and flag=0) do
    DRAWARROWDOWN(barindex, high+5) COLOURED(255,215,0)
    flag=1
    break
    wend
    
    while (flag=1 and close<open-1) do
    DRAWARROWDOWN(barindex, high+5) COLOURED(255,0,0)
    flag=3
    break
    wend
    
    endif
    #210250 quote
    JS
    Participant
    Senior

    Hi @Pippone1987

    Maybe you can use this as a starting point…

    DefParam DrawOnLastBarOnly=True
    
    If Close > Close[1] and Close > Open[1] then
    DrawArrowUp(BarIndex, High+5) Coloured("Yellow")
    
    EndIf
    
    If Close < Open then
    DrawArrowDown(BarIndex,High+5) Coloured("Red")
    EndIf
    
    Return
    #210281 quote
    pippone1987
    Participant
    New
    Ok I’m going to perform some test to understand if it fits the intended behavior. Thanks @JS
    JS thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Change arrow color in realtime according to a condition


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/23/2023
Status: Active
Attachments: No files
Logo Logo
Loading...