Supertrend conditional order recursion error


Category:
0
0

Hello,

I would like to autotrade supertrend in thinkorswim.

input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;
input PaintBars = yes;
def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
plot SuperTrend = if ST crosses below close then +1.0 else 0.0;

I get the recursion error when I try to use it.  Is there a way to modify the code to use it for autotrade?

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on June 5, 2020 2:55 am
306 views
0
Where do you see the recursion error and did you ever solve it? I have a recursive variable problem in a strategy too. Cheers
( at June 9, 2020 8:24 pm)
0
There is no blanket solution. Each code must be evaluated on it's own to see if it truly requires recursion for it's computations. Recursion is almost always used because it is required. It is rarely used by accident. So chances are very slim that any code which uses recursion can be modified to work without it.
( at June 9, 2020 9:43 pm)
0
Agreed. I’m just wondering if he came up with a creative solution around the limitations of TS. I only have to use recursion maybe once a year. And everytime I do, I usually regret it. Cheers
( at June 10, 2020 8:00 am)
0
You mentioned "limitations of TS", however that would refer to TradeStation and I think you actually meant Thinkorswim "TOS"? Recursion on Thinkorswim is unsupported only for Study Alerts and Conditional Orders. If recursion is required for a trading method that is crucial to your success (using one of those tools) you can move to TradeStation where such restrictions do not exist.
( at June 10, 2020 11:01 am)
0
Private answer

Sorry but was not able to discover a way to remove the recursion and still generate the signal you included. Not within the limited time I have available for free solutions in the Q&A forum.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 5, 2020 7:57 am