Once again thanks for your help with the label of the Advanced Declined Cumulative Average. My apologises for having another question with regards to labels.
I will like to add the days to earnings column to the watchlist. I have actually create the column based on what you recommend in a previous question posed on the forum based on the GetEventOffset function in TOS. However, i will like to change the colour of the number (as in the number of days) in the column. I am looking at
If number of days is more than 7, green numbers. if number of days is 7 or less, red colour. Appreciated if you can help me once again. Thank you
Marked as spam
Please keep this details in mind as you post new questions in this forum.
Here is the code for the solution you requested. I took the code from the previous solution I linked to in bullet point 3 and I added two lines of code. One to contain the number of days and another to dynamically set the color of the value based on that number.
Marked as spam
Noted on your comments. And your code works perfectly. Thanks a lot. You have make my charts and columns so much more comprehensive. By the way, i just found a thinkscript code below that manages to exclude the negative sign for days. However, i cant seem to get the label right. Any days less than 7 becomes a NaN on the column. How can i modify the label? def bn = BarNumber(); def na = Double.NaN; def getNextEarnings = AbsValue(GetEventOffset(Events.EARNINGS, 0)); def findDay = GetDayOfMonth(GetYYYYMMDD()); def findMonth = GetMonth(); def findYear = GetYear(); def getNextEarningsBarNumber = if !isNaN(getNextEarnings) then bn + getNextEarnings else na; def NextEarnings = bn == HighestAll(getNextEarningsBarNumber); def getNextEarningsMonth = HighestAll(if NextEarnings then findMonth else na); def getNextEarningsDay = HighestAll(if NextEarnings then findDay else na); def getNextEarningsYear = HighestAll(if NextEarnings then findYear else na); plot DaysToEarnings = getNextEarningsBarNumber; DaysToEarnings.Hide(); AddLabel(getNextEarnings > – 0, ”” + getNextEarnings + if getNextEarnings > 1 then ”” else ””, Color.green); AddLabel(getNextEarnings < 7, "", Color.RED);
I can tell you how to reverse the negative value to a positive value on the solution that I provided. Change the last TWO lines of code to the following: plot data = GetEventOffset(”eventType” = Events.EARNINGS) * -1; data.AssignValueColor(if data > limit then Color.GREEN else Color.CURRENT);
Again it works. Thanks so much. You are a great help. But i am sorry that i need to ask how can we delete the decimal point? Right now it is 30.0 or 4.0. I am using this code input limit = 14; plot data = GetEventOffset(”eventType” = Events.EARNINGS, + Round (data, 2)) * -1; data.AssignValueColor(if data > limit then Color.light_GRAY else Color.yellow); But the code doesnt work with the reason being: Too early to access data at 3:69 Only constants expected here: data CL dynamic param at 3:69 I am sorry to trouble you again
It is not possible to delete the decimal point. Your modification creates invalid syntax. You will just have to live with the decimal points. It may be possible to convert those values to text, in which case you would have to replace the plot statement with an AddLabel() statement. But then you loose the ability to sort your watchlist by those values. Try not to fuss over things that don't matter and focus on accomplishing what you need to perform task as a trader.
Hi Pete, yeah i agreed. Thanks a lot for your help. Really appreciated you taking your time to help us. But probably need some help with regards to bid ask spread label soon. But for now, let me go through what will really help me in my trading before asking you. Have a good end to year..Cheers
Please log in to post questions.