♥ 0 |
I was looking for a way to create a custom column in the TOS watchlist that would give me the % change from the current days open to the current day market price. TOS has a %Change column but it calculates from the previous days close. I found a question by Two Way Trader about a month ago that you answered in the TOS watchlist forum . I was able to modify the code you gave him (or her, not sure) to achieve the results I was looking for. Not completely sure how the code works but it does. I also added some code to give color to the back ground and numbers. Please see below the code I came up with. If you would be kind enough I would like to hear an explanation to how my changes made this work and/or suggest a better code solution? Thanks. def startTime = 0900; def regularSessionstart = SecondsTillTime(startTime) == 0; rec dailyOpen = if regularSessionstart then close else dailyOpen[1]; plot percentChange = 100 * (dailyOpen / open – 1); PercentChange. AssignValueColor(if percentChange > 0 then Color.GREEN else if percentChange < 0 then Color.RED else Color.BLACK);
Marked as spam
|
Private answer
If this is the previous solution you are referring to.... https://www.hahn-tech.com/ans/show-change-since-open-in-column/ Then your solution does not exactly do the same thing. The default value you set for the "startTime" input is not the regular session open. That would be 930 instead of 900. But perhaps you had a reason to use a different time than the regular session open. In regards to the assignment of color, that seems be applied correctly. In the solution I linked at the top if my response, the solution was to apply a daily time frame to the watchlist column. Which does not require the use of a session start time. So if you wanted to apply the color changes to my previous solution, it would look like this:
Set that to a daily time frame it you are automatically assured of getting the open of the regular session. Marked as spam
|
Please log in to post questions.