Reduce complexity error (TOS)


Category:
0
0

Hello there! I have been following this site for quite some time and it helped learn how to code thinkScript easily! Unfortunately, I am stuck with my current codes since TOS shows “complexity error” even though my codes are correct. I would like to ask what makes a code complex? Which contributes most to the complexity of the codes: operators (and, or), if-then else statements, # of rows? Lastly, I have been having a hard time shortening the codes having multiple if statements. I hope you can give me tips! Thank you very much in advance!

Marked as spam
Posted by (Questions: 5, Answers: 6)
Asked on June 10, 2020 3:50 am
811 views
1
Private answer

You posted this in the Frequently Asked Questions topic but I moved it to the Stock Scanners topic. Custom scans are the most likely place where these complexity errors appear so I felt it most appropriate to place it here. We have no clue where your error is occurring or why because you did not provide any code and you did not explain what tool your are trying to apply your code to.

I understand you felt that we could provide general tips and suggestions. But there are very few. Each code must be evaluated separately and I have not yet identified a complete list of things to avoid the "TooComplexException" error.

This has been posted in the Q&A forum before but it may be difficult to locate because folks will rarely use the full name of the error. When folks don't know anything about writing code they don't realize the importance of precise details.

Such as the full text of the error: "gettingcom.devexperts.tos.thinkscript.runtime.TooComplexException: The complexity of the expression suggests that it may not be reliable with real-time data error."

When I search the Stock Scanners topic for the term "complexity" I find the following posts:

https://www.hahn-tech.com/ans/trend-reversal-scanner/

https://www.hahn-tech.com/ans/relative-volume-by-time/

There are some very helpful tips in those posts, but only because the authors of the posts provided their code as well as sufficient details required to evaluate and diagnose the problem.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 10, 2020 8:07 am
0
Thank you! I will try to work around it!
( at June 11, 2020 1:08 am)