♥ 0 |
Hello, I am trying to add chart labels for multiple time-frame(15 min, 30 min, hour) on a 5 minute chart. The labels appear only for 5 min and 15 min after I comment out the code for 30 min and 1 hour. If I do not comment out the code for 30 min and 1 hour then it does not even show labels for 5 min and 15 min. Please see attachment for details. I have the following code. #5 min chart #15 min chart #30 min chart #1 Hour chart
Marked as spam
|
Private answer
I tested this as thoroughly as I could and you are correct. I could not find a cause. I did find that it’s only the thirty min time frame causing the error. You can substitute “AggregationPeriod.FIFTEEN_MIN” in place of “AggregationPeriod.THIRTY_MIN” and the hourly label will work. When chart studies do not plot, be sure to check the upper left hand corner for an error message. See attached screenshots for detail. There is an exclamation mark inside a circle. Click that whenever you see to get a list of problems generated for that chart. In this case it tells us that “Two different secondary periods cannot be used within a signal variable”. However it is perfectly clear you code does NOT break this rule. The platform is misinterpreting things. I recommend you submit this to TDA support for analysis. In your code there are some minor issues with style. You have gotten the capitalization rules backwards. User defined inputs and variables should always begin with lowercase. System constants and methods should always begin with a capital letter. The data objects for chart data always begin with a lowercase letter (open, high, low, close, volume). Whenever you are not sure just look at the examples provided by Thinkorswim in their language reference: http://toslc.thinkorswim.com/center/reference/thinkScript/Constants/AggregationPeriod/AggregationPeriod-FIFTEEN-MIN.html Here is a cleaned up version of your code that corrects all of these style issues:
In closing I will leave you with a few more tips. Always place your inputs at the very top of your code, grouped together as you see here. When testing if a variable is true, there is no need to use “= 1”. Notice that I only need to say: Those changes don’t make the code work. But it makes it easier to read and maintain. It’s something in the platforum that is broken. The code should work fine. Good luck! Marked as spam
|
Please log in to post questions.
Thanks a lot for looking into it! I have the code as below that you suggested but no labels appear after I add the code for hourly time frame.
input period5 = AggregationPeriod.FIVE_MIN;
input period15 = AggregationPeriod.FIFTEEN_MIN;
input periodHour = AggregationPeriod.HOUR;
#5 min chart
def greenCandle5 = close(period = period5) > open(period = period5);
AddLabel(yes, “X5”, if greenCandle5 then color.CYAN else color.YELLOW);
AddLabel(yes, “||”, color.VIOLET);
#15 min chart
def greenCandle15 = close(period = period15) > open(period = period15);
AddLabel(yes, “X15”, if greenCandle15 then color.CYAN else color.YELLOW);
AddLabel(yes, “||”, color.VIOLET);
#1 Hour chart
def greenCandlehour = close(period = periodHour) > open(period = periodHour);
AddLabel(yes, “XHour”, if greenCandlehour then color.CYAN else color.YELLOW);
AddLabel(yes, “||”, color.VIOLET);
I did not indicate the changes to the code would make it work. In fact I explicitly stated that these changes would NOT make it work.
Quote: “Those changes don’t make the code work.”
The changes I made were to correct errors in your style of coding. This is so that you can submit this to Thinkorswim and the developers that assist you will see that you have VERY clean code.
I also clarified the source of the problem: “It’s something in the platform that is broken. The code should work fine.”
This means that the problem is inside the platform itself. There is nothing wrong with that code. It should work but does not. Which means the problem is inside the platform itself. Your only course of action here is to submit this to Thinkorswim support.
And yes, I did notice you tried to apply this without including the 30 min time frame label. Yesterday it was working when I included the 1 hour time frame. Today it is not. This only further confirm something inside Thinkorswim is broken.
Thank you! I have sent the code to TDA support as to why it’s not working as expected.