rottentrade
Member
From what I understand, you would use "if...if else...else" statement to combine more than one IF statement.
However, in my case, for testing purposes, I need to use 2 IF statements in a chart bubble and each of them clearly needs to state A or B . So essentially there will be 2 pairs of TRUE/FALSE. But I can't use "AND" to combine the two IFs in one line.
Here's my code:
input order = {default buy, buynhold, sell, sellnhold};
def order1 = order == order.buy or order == order.buynhold;
def order2= order == order.buynhold or order == order.sellnhold;
AddLabel(1, if order1 then “buy” else “sell” AND if order2 then “& Hold” else “”, Color.LIME);
----------------------------------
Error message:
Expected double
Wrong type cast: different types after then and else: double vs class java.lang.String
----------------------------------
However, there's no problem when I write out two separate if statements.
input order = {default buy, buynhold, sell, sellnhold};
def order1 = order == order.buy or order == order.buynhold;
def order2= order == order.buynhold or order == order.sellnhold;
AddLabel(1, if order1 then “buy” else “sell”, Color.LIME);
AddLabel(1, if order2 then “& Hold” else “”, Color.LIME);
How would I bypass this problem without using the "AND" function?
However, in my case, for testing purposes, I need to use 2 IF statements in a chart bubble and each of them clearly needs to state A or B . So essentially there will be 2 pairs of TRUE/FALSE. But I can't use "AND" to combine the two IFs in one line.
Here's my code:
input order = {default buy, buynhold, sell, sellnhold};
def order1 = order == order.buy or order == order.buynhold;
def order2= order == order.buynhold or order == order.sellnhold;
AddLabel(1, if order1 then “buy” else “sell” AND if order2 then “& Hold” else “”, Color.LIME);
----------------------------------
Error message:
Expected double
Wrong type cast: different types after then and else: double vs class java.lang.String
----------------------------------
However, there's no problem when I write out two separate if statements.
input order = {default buy, buynhold, sell, sellnhold};
def order1 = order == order.buy or order == order.buynhold;
def order2= order == order.buynhold or order == order.sellnhold;
AddLabel(1, if order1 then “buy” else “sell”, Color.LIME);
AddLabel(1, if order2 then “& Hold” else “”, Color.LIME);
How would I bypass this problem without using the "AND" function?
Last edited: