Script Processing Efficiency

Are there rules defining how scripts are executed with respect to performance. For example:

x and y and (a > 20) and (a.DMPlus > a.DMMinus) and (ATR() > 0.25) and (MA(VOL(), BARS=50, CALC=Close) > 100000)

Does the processing of the last AND line stop as soon as a criteria fails? Say ‘x’ is not an outside bar. Are all the calculations processed or does the interpreter stop after the first FALSE from left to right?

Hi Andy,

Quick answer is no - it does not stop. The reason is that we use what we call vector scripting. That means for each calculation we don’t just have a single value but a complete history of that calculation through time. That’s why you can add a script like this in a Show Plot and see when it was true in the past. To even get a value for today, we need the full history in case today’s value was dependent on the history (like in a weighted moving average).

The optimization you are talking about makes sense when there is only a single value, but not in this style. The extra milliseconds which would be saved is not worth the weeks of development it would take us to implement that. Instead our focus is on keeping the processing of the vectors as fast as possible.

All the best


Thanks Mathew. I agree it isn’t worth the effort. I was just wondering what was happening behind the scenes.