Draw a line at a certain position depending on the symbol


Category:
0
0

Hi

This code work fine unless it is a FUTURE symbol

what im missing here ?

def X = if getSymbolPart(1) == “/ES” then 2700 else
if getSymbol() == “SPY” then 270 else
Double.NaN;

plot line = X ;

Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on February 9, 2019 1:20 pm
552 views
0
Private answer

Well there are two reasons. One is the use of “GetSymbolPart(1)”. That method is used for compound symbols. Something like a “pairs chart” where you subject one symbol’s values from another (IBM-AAPL).

But for some reason “GetSymbol” does not work either. I am not sure why by you should take that up with thinkscript support.

I can give you a workaround. Be careful when using this because if that futures symbol ever ceases to exist your code will fail and require modification.

def X = if close("/ES") > 0 then 2700 else if getSymbol() == “SPY” then 270 else Double.NaN;

Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on February 12, 2019 3:05 pm