label showing when close is greater than custom HL2


Category:
0
0

Hi Pete, 

I am loooking for labels to be added in the code.

http://tos.mx/NU4Zarz

Label 1- Close Greater Than HL2=YES 

Label 2- Close Greater Than HL2=NO

But I need only one of the labels to be displayed based on the close value in referece to HL2. 

Can you please help?

Thank you, 

Shaishav

RESOLVED
Marked as spam
Posted by (Questions: 49, Answers: 62)
Asked on February 1, 2020 5:11 pm
52 views
0
Private answer

Please include the code within the body of your question or as an attached plain text file. The share links generated by Thinkorswim have an expiration date and they can be revoked. They are not suitable for posts in a Q&A forum that will persist for years.

In your request it seems you gave the same conditions for when the label should display YES as well as NO. So I will take that as a typo and provide a solution so that the label displays YES when close is greater than hl2 and NO when the close is less than hl2.

Here is you code, cleaned up a bit to make it easier to read and remove some unused lines. I have added only one line of code to produce the label you requested.

input aggregationPeriodForHL2 = AggregationPeriod.FIVE_MIN;
def highValue = high(period = aggregationPeriodForHL2);
def lowValue = low(period = aggregationPeriodForHL2);
plot hl2 = Round((highValue + lowValue ) / 2, 2);
hl2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hl2.SetStyle(Curve.FIRM);
hl2.SetDefaultColor(CreateColor(255,255,255));
AddLabel(yes, Concat(“HL2 : “, hl2 ), Color.WHITE);
AddLabel(yes, if close > hl2 then "YES" else "NO", Color.WHITE);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 2, 2020 9:31 am
0
Thank you Pete , I was not aware about the expiry dates on link so will not make the same mistake again. I appreciate your help.
( at February 2, 2020 9:38 am)