Love ThinkScript but it can be frustrating as well. Here's my problem:
I want to put up a label indicating the last order placed during backtesting. My attempt to use getQuantity(getSymbol()) isn't working. Here's my code:
With this code, the script blows up - no orders, no FloatingPL, no label - nothing
Without this code, I get orders, FloatingPL, but no label (of course)
I want to put up a label indicating the last order placed during backtesting. My attempt to use getQuantity(getSymbol()) isn't working. Here's my code:
Code:
def isLong = getQuantity(getSymbol()) > 0;
def isShort = getQuantity(getSymbol()) < 0;
AddLabel(yes,
if isLong then "Buy"
else if isShort then "Short"
else "Neutral",
if isLong then Color.DARK_GREEN
else if isShort then Color.DARK_RED
else Color.GRAY);
With this code, the script blows up - no orders, no FloatingPL, no label - nothing
Without this code, I get orders, FloatingPL, but no label (of course)
Last edited: