Colors a curve with the color you defined using the RGB convention.
Syntax:
1 |
COLOURED(R,G,B) |
or
1 |
COLOURED("colorname") |
where colorname is a pre-registered color definitions:
The expression COLOURED must be place just after the value name :
1 |
RETURN myValue COLOURED(50,50,75) |
Since the prorealtime version 10.3, it is also now possible to add “alpha” value for transparency purpose:
Syntax (v10.3) :
1 |
COLOURED(R,G,B,alpha) |
Alpha value varies from 0 to 255.
RGB color samples :
Syntax(v11):
COLOURED expression can also be associated within the word “BY” to color a curve with colors chosen in the indicator parameters window here :
Example of line made of 2 colors :
1 2 3 4 5 6 7 8 9 10 |
i1 = average[10](close) i2 = average[50](close) if(i1>i2) then a = 1 else a = -1 endif RETURN i2 coloured by (a) |
The line is colored by (a) variable through our conditions :
HI,
I was just wondering if it is possible to change colour depending on value of indicator so for example could a value like 10 be GREEN and a value of 5 be ORANGE ?
yes of course.
If value=10 then
r=0
g=255
b=0
endif
RETURN value coloured(r,g,b)
Change r,g,b variables the way you want your returned value to be coloured .
Is it possible to mix “coloured by” with transparency?
I mean i want to fix the 2 possible colors from indicator settings, but i want to be able to tune the transparency of those color by code.
If it was possible I wouldn’t want to create 6 inputs to fix r, g, b values manually from the inputs (I prefer the color picker if possible)…
No you can’t mix COLOURED BY with coded alpha transparency.
PRT doesn’t leave us to write “DRAWTEXT(….) COLOURED BY (1)”, it seems we can use “BY” only with “RETURN” command
That’s right. Use R,G,B values as standard variables instead.