PureBytes Links
Trading Reference Links
|
Hi Christian,
I think what everybody is trying to say is that your statement:
If currentbar > maxbarsback then
ind=ind[1] + 1;
Is like saying: If 1 > 0 then
ind=ind[1] + 1;
In other words the starting statement is always true - therefore
ind=ind[1] +1 will try to go on forever - no way out - 1 is always
greater then zero. ie "Infinite loop Error"
You need to have the calculation - ind=ind[1] + 1; - dependent on some
statement that does have an end - that is false under some condition -
and that condition can not keep the code looping too long. TS has a
built
in timing function that checks for, what it considers an "Infinite
loop",
if you exceed that time you get an "Infinite loop Error".
Larry
Christian wrote:
> On 25 Aug 2005 at 18:35, Chris Cheatham wrote:
>
> > There appears to be no end to your loop...if currentbar> maxbarsback
> >....it will always be > maxbarsback...
>
> ??!? Thank you for your suggestion but "If currentbar > maxbarsback"
> isn't a loop...
>
> Does anyone know how can I get rid of this weird "Infinite loop Error"
> in the following example ?? (under TradeStation 8.1 build 2706).
> This error isn't triggered when applied to a chart with only a few
hundred
> or thousand bars...
>
> Any other suggestion?
>
> ------------------ Example - Just Cut & Paste ------------------
> [InfiniteLoopDetect = FALSE]
> { New in TradeStation 8.1 - It should help but it doesn't.... }
>
> var : ind(0);
> array : float Indicator[](0);
>
> if CurrentBar > MaxBarsBack then
> begin
> ind=ind[1] + 1;
> Array_SetMaxIndex(Indicator,ind);
> Indicator[ind]= CCI(10);
> end;
>
> if LastBarOnChart then
> value1=SortArray(Indicator,ind,1);
>
|