Help Needed with Conditionals on AddLabel



New member
Hello all.. I am looking for some assistance with this script.. I am trying to code an AddLabel script to display whether we're opening up above, below or inside yesterday's trading range.. here's what I am having trouble with:

AddLabel(yes, if op < PrevDayLow then "Below yRange" else if op > PrevDayHigh then "Above yRange" else "Inside yRange");

I have defined prior day's high/low as "PrevDayHigh & "PrevDayLow" and todays open as "op".. I want the code to display "Below yRange" if open < yesterday's low, "Above yRange" if open > yesterday's high, and "Inside yRange" if the open is between yesterday's high & low..
I am getting an error message I've not seen before.. the code itself is not highlighted red like when it's wrong, but TOS won't let me save/apply the code because of the error message.. the "apply" button is grayed out and when I press "ok" the script is displayed in red as it contains an error.. the error message is:

Wrong type cast: different types after then and else: double vs class java.lang.String

I cannot figure out what I am doing wrong..

Thanks in advance!


Well-known member
2019 Donor
This way will work.

AddLabel(yes, if open < low[1] then "Below yRange" else if open > High[1] then "Above yRange" else "Inside yRange");

Similar threads