Hello!
I have been using the community for a while with all the scripts around already,
But it is my first time posting requesting help of something I am trying to do:
I'm having issues changing the color of a plot according to a conditional (which would be price).
I'm well concerned that the "AssignValueColor" shall be used for this but I am having a problem on the constant to retrieve the value.
#Line.AssignValueColor( if Line > "x" then Color.UPTICK else Color.DOWNTICK);
Full code:
As simple as it is.
Being "X" the candle open ( or last candle close, no problem)
Basically I just want the line plotted above to be green or red, same color as the candle actually, or the price bubble on the right axis itself.
But nothing I do seems to work. I've tried from def, to input, to close, or close - close[1], price = close, up to Set "Up" and "Down" colors an so on a lot of different stuff but nothing seems to work.
The condition actually works, if I manually add a price under "X" I can see line changing according to up or down that value
(but it is not something I'll be doing for every candle of course lol I just tried to see if the other arguments were right)
So, any clue, anyone?
Thank you in advance!
Appreciate you guys and this helpful community.
I have been using the community for a while with all the scripts around already,
But it is my first time posting requesting help of something I am trying to do:
I'm having issues changing the color of a plot according to a conditional (which would be price).
I'm well concerned that the "AssignValueColor" shall be used for this but I am having a problem on the constant to retrieve the value.
#Line.AssignValueColor( if Line > "x" then Color.UPTICK else Color.DOWNTICK);
Full code:
Code:
input price = close;
input offset = 0;
input length = 0;
def sma = SimpleMovingAvg(price, 1, length);
rec line = if IsNaN(sma) then line[1] else sma[offset];
plot priceline = if IsNaN(sma) then line else Double.NaN;
priceline.setpaintingStrategy(paintingStrategy.DASHES);
priceline.setdefaultColor(Color.White);
#priceline.AssignValueColor( if priceline > "open?/lastclose?" then Color.UPTICK else Color.DOWNTICK);
As simple as it is.
Being "X" the candle open ( or last candle close, no problem)
Basically I just want the line plotted above to be green or red, same color as the candle actually, or the price bubble on the right axis itself.
But nothing I do seems to work. I've tried from def, to input, to close, or close - close[1], price = close, up to Set "Up" and "Down" colors an so on a lot of different stuff but nothing seems to work.
The condition actually works, if I manually add a price under "X" I can see line changing according to up or down that value
(but it is not something I'll be doing for every candle of course lol I just tried to see if the other arguments were right)
So, any clue, anyone?
Thank you in advance!
Appreciate you guys and this helpful community.
Last edited: