"E21: For-Loop is probably infinite"

Post Reply
pablo
Posts: 15
Joined: 15 Sep 2014 14:24

"E21: For-Loop is probably infinite"

Post by pablo »

Hi,

I have a problem with running Express code on large portion of data. Up to approximately 150 000 bars on chart it works fine, but above that I get
"E21: For-Loop is probably infinite".

I assume that there is some kind of "security" switch that triggers above certain number of iterations - how do I turn it off. Or how do I change the number to a bigger value?
Or is it rather matter of time consumed to calculate, than number of iterations? If so, I want to increase upper limit of time allowed for calculation.

anybody had such a problem before?

thx

P
User avatar
WHS Support
Posts: 2430
Joined: 14 Feb 2013 10:27

Re: "E21: For-Loop is probably infinite"

Post by WHS Support »

Dear Pablo,

this message is thrown if a calculation takes longer than 5 seconds. In live trading, this can lead to serious performance issues. Therefor the warning.
The express code, nevertheless, is still running.

Regards
Dominic
WHS
pablo
Posts: 15
Joined: 15 Sep 2014 14:24

Re: "E21: For-Loop is probably infinite"

Post by pablo »

Dominic,

I understand that in live trading it is not acceptable. And from what I noticed Express code is not running anymore, because sentimnetor gets deactivated.

Let's say I want to run backtest on 5 years of 1 minute bars. It will probably be around 1 500 000 bars. I accept that time needed to calculate the strategy will be longer than 5 seconds. And still want to do it. How do I disable the warning?

In live trading probably 1 month of 1 minute bars will be enough lowering number of bars to 30 000, so my code will calculate no problem.

thx

P.
pablo
Posts: 15
Joined: 15 Sep 2014 14:24

Re: "E21: For-Loop is probably infinite"

Post by pablo »

WHS Support, Dominic

Any solution how to disable the warning? Or change the 5 second limit to higher number?

Pablo
User avatar
WHS Support
Posts: 2430
Joined: 14 Feb 2013 10:27

Re: "E21: For-Loop is probably infinite"

Post by WHS Support »

Hello Pablo,

would it be possible to send us the study by mail?
We would like to have a look inside to find the root cause. OK?

Best regards,
Iris

Iris Heinen for WH SelfInvest
pablo
Posts: 15
Joined: 15 Sep 2014 14:24

Re: "E21: For-Loop is probably infinite"

Post by pablo »

Hi Iris,

The problem I am touching right now is way more severe than just time needed to calculate the express code.

I would never go into trouble to write the complicated code just for fun. But I am forced to, because when building Span Bars, Nano Trader cheats and give user false results. Using 0,3% span for DAX futures (10 euro round trip cost) without much time needed to optimize strategy I get these results:
DAX misleading results.jpg
They looke very good but are completly false. The way Nano Trader creates span bars (on 1 minute aggregation) is a mystery. Here's an example:
DAX 200T range Nano Trader.jpg
and in detail:
DAX 200T recent Nano Trader.jpg
The range is calculated with this:

Express ATR_Averag

vars

series
myRange;

calculation

CalculateAtEveryTick(false);

myRange = (High - Low);

interpretation
begin
end

plot(myRange,black,2);

The size of bars is set to 100 points (200 Ticks). So why they almost never reach this number? They are not even close to being 100 points in size!
Closing bar at end of day is responsible for only few occurences - the rest to me looks like is being created with "knowing the future". Because the span bar is terminated when adding next 1 minute candle to the bar "in progress" would exceed desired size. It is not only an issue with Span Abs, but Span% as well.

There are several problems with it:
1. First as a user a am being cheated. The test results that I am getting are taken out of the blue.
2. There is no way to use Span Bars in live trading, becaouse then Nano Trader uses Tick aggregation - and all Bars are in fact 100 points (exept for the bars at end of day).
3. And the mose important - in live trading - I do not know the future... so can't even try to replicate the algorithm responsible for creating Span Bars.

So the way to use Span Bars is to bypass limitations of Nano Trader...

//rest in next part due to 3 attachment limit
You do not have the required permissions to view the files attached to this post.
pablo
Posts: 15
Joined: 15 Sep 2014 14:24

Re: "E21: For-Loop is probably infinite"

Post by pablo »

//second part

Here's the code for calculating Span Bars one by one:
Range_Bars_Bypass.txt
So the actual Span of 100 points (200 Ticks) bar is NEVER smaller than 100 points:

all:
DAX 200T range.jpg
recent days:
DAX 200T recent.jpg
This sentimentor is acctually only the base for calculating strategy - adding moving averages, standard deviation, ATR, indictors etc....
Then loading few years of 1 minut bars is way to much to be calculated in 5 seconds. For obvious reasons I don't want to give it away.

The easiest choice would be to fix the algorithm that creates Span Bars in Nano Trader. I already have some ideas what features would be appreciated by users, and would make Nano Trader really good trading platform.
And then give users choice how they want Span Bars to be terminated (Tick/1 minute/5 minute aggregation; end of day termination? etc). So then all test results are valid and strategy can be taken into LIVE trading.

The other way is to give user tool then takes out 5 second limit for calculating a code.

What do you choose?

Pablo

ps. There's third way - do nothing. Hope you will not go this way.
You do not have the required permissions to view the files attached to this post.
User avatar
WHS Support
Posts: 2430
Joined: 14 Feb 2013 10:27

Re: "E21: For-Loop is probably infinite"

Post by WHS Support »

Hello,

we are getting more and more in IT details and special features here in the forum.
As the next step we ask you to contact our client service by mail indicating your account identification.
Our client / IT support will be very happy to clarify all your questions via this medium or phone.

Best regards,
Iris

Iris Heinen forWH SelfInvest
Post Reply

Return to “WHS NANOTRADER - EXPRESS PROGRAMMING”