♥ 0 |
Hello traders, I found this script a while back that attempts to plot the ytd% return on a tos watchlist column, but I keep getting notified of a script error at the bottom. Also trying to make it where above 1% returns are green…. and below -1% returns are red. Any help correcting this would be appreciated. Thanks guys. Happy trading #def allows you to teach ThinkScript new “words” that you can reference later in your code #GetYYYYMMDD() returns today’s date #there are 252 trading days each year def yearstart = getyear() * 10000 + 101; def tradedays = countTradingDays(yearstart, GetYYYYMMDD()); def closeEOY = getvalue(close, tradedays, 252); def YTDnetchange = ((close – closeEOY)/closeEOY) * 100; #YTDnetchange could have been the plot line, however to view results with a limited number of decimal places that line was another def or definition for ThinkScript. And a new “word” value was used for the plot line in this code. 2 means round to 2 decimal places plot value = round(YTDnetchange, 2); RESOLVED
Marked as spam
|
Please log in to post questions.
Hello Pete………is there a way to add the “%” to the end of each of the values?
You can. But that column will not sort correctly. You can see how it’s done in this post: https://www.hahn-tech.com/ans/how-to-create-a-watch-list-that-calculates-change-in-last-5-minutes/
ok thanks