There were a few changes required before I could approve this question for the forum:
- Questions regarding the Conditional Order tool should be located in the "Strategy Guide" topic, so I moved this question out of "Frequently Asked Questions" (which should never be used anyway).
- The title of your question did not include the details which would provide other viewers the context required to find this solution using the search box. So your title has been updated to include those essential details.
- Ordinarily, this type of question would not be approved in this forum because we do not provide one-off solutions which only serve a single individual. However by changing the title I have adapted your question so that it does serve the interest of a wide range of our viewers.
I just wanted to clear up those details so when you post questions in the future you understand the goals of this forum. Which is to solve the most commonly asked questions among traders.
Now that we have cleared up those details I will explain why your code is not supported in the Conditional Order tool on Thinkorswim.
- Your code includes references to a secondary aggregation period, which is not supported in the current version of Thinkorswim.
- Your code includes a recursive variable, which is also not supported in the current version of Thinkorswim.
Where is this reference to secondary aggregation? Here:
(period = aggregationPeriod.FIVE_MIN)
Each section of code which includes this reference is not supported in the Conditional Order tool. If you paste your code directly into a Conditional Order you will find it generates an error stating "Secondary period cannot be less than primary". And this error persists no matter what time frame is selected for the Conditional Order. However if you tried to save this as a custom study and used only a reference to the study in the Conditional Order the compiler may miss this. Which is why we always recommend that we never reference custom chart studies in this tool. We always want to use the entire code.
Where is the recursive variable?
def deltaClose = deltaClose + delta;
Any variable which refers to a previous value of itself (
deltaClose) is a recursive variable. These are not supported in the Conditional Order tool on the current version of Thinkorswim.
For those interested in learning how to avoid these types of mistakes I suggest the following videos: