Hello, im creating a study where I simply draw horizontal lines for each stock. So each stock I list has a different value.
So as you can see, I will have a list of prices for each stock to draw specific horizontal lines on many charts. I just included 3 stocks for simplicity sake.
But my main question is this. Right now the line is shown to be dotted Orange line for all stocks. Is there anyway to color code the line to show up as ORANGE when P1>current stock close, and GREEN when P1<current stock close?
So for AAON, P1 is 48.95. current price for AAON is 72.74. so the line should be Green. And if the current price was 40, then it would be orange. Not sure how to get this in the code.
Basically im trying to distinguish which is higher, P1, or current price. If I cant change the color of the line, then maybe a chart label? Something to make it more obvious.
thanks in advance!
So as you can see, I will have a list of prices for each stock to draw specific horizontal lines on many charts. I just included 3 stocks for simplicity sake.
But my main question is this. Right now the line is shown to be dotted Orange line for all stocks. Is there anyway to color code the line to show up as ORANGE when P1>current stock close, and GREEN when P1<current stock close?
So for AAON, P1 is 48.95. current price for AAON is 72.74. so the line should be Green. And if the current price was 40, then it would be orange. Not sure how to get this in the code.
Basically im trying to distinguish which is higher, P1, or current price. If I cant change the color of the line, then maybe a chart label? Something to make it more obvious.
thanks in advance!
Code:
AddLabel(No, GetSymbol());
plot p1;
p1.SetDefaultColor(Color.orange);
p1.SetLineWeight(5);
p1.SetStyle(Curve.LONG_DASH);
def nan = Double.NaN;
if (GetSymbol() == "AAON")then {p1 = 48.95;} else
if (GetSymbol() == "AAPL")then {p1 = 85;} else
if (GetSymbol() == "ZTS")then {p1 = 125;} else
{ p1 = nan; ;}