♥ 0 |
https://www.hahn-tech.com/ans/price-for-a-specified-date/ discusses how to define a price for a previous date using the code def priceAtDate = if GetYYYYMMDD() == 20170103 then close else Double.NaN; That code gives a value only for the single day 20170103 and doesn’t have a value for other days.
How can I use the priceAtDate value for calculations on other days For example def priceAtDate = if GetYYYYMMDD() == 20211101 then close else Double.NaN; #https://www.hahn-tech.com/ans/price-for-a-specified-date/ plot scan = priceAtDate; plot close – scan; <- TOS says this line is invalid
Marked as spam
|
Private answer
The only part you are missing the name of the plot variable. This is what you last line should look like:
I used a rather ridiculous name for the variable name of the plot statement so that you can see where it needs to be placed. And you must have the equal sign immediately following the name of the plot variable. Want to learn more? Here is a link to the Thinkorswim language reference that covers the plot statement: https://toslc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/plot Thinkorswim also provides an only tutorial that explains how to begin writing custom trading tools: https://toslc.thinkorswim.com/center/reference/thinkScript/tutorials/Overview
Marked as spam
|
Please log in to post questions.