[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Looping or optimizing a set of non sequential numbers?



PureBytes Links

Trading Reference Links

Actually...hold on. I posted two versions of the code (one with arrays, and one with static variables) and *both* versions do not capture all the numbers in the text file.

As mentioned, the following version only sees less than 3,000 numbers even though the text file contains 5000. And it uses dynamically named static variables. What is wrong with this code?


Count = 0;

if(Status("ActionEx") == actionExOptimizeSetup)
{
count =
0;
fh =
fopen("c:\\TestExtractFile03.txt", "r");

if (fh)
{
  
while(!feof(fh))
  {
  
StaticVarSet("Row"+NumToStr(Count,1.0,0), StrToNum(fgets(fh)) );
  
StaticVarSet("Count", Count);  
  Count++;  
  }
fclose( fh );
}
else
  {
  
printf("ERROR: file can not be found (does not exist)");
  }  
}


b =
Optimize("b", 9, 1, Count, 1);

Count =
StaticVarGet("Count");

for(a = 0; a < Count; a++)
{
Row =
StaticVarGet("Row"+NumToStr(a,1.0,0));
printf("Row: %g\n", Row );
}

Buy  = a == 12; // random buy/sell conditions for test purposes
Sell = a == 2;







--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote:
>
> Ah! That must be it. I was confused why I was sometimes seeing
> subscript out of range errors based on barcount, even though I was not
> actually referencing any bars. I didn't realize that even non-bar
> based arrays are also limited to barcount. Kinda weird that such would
> be the case, but guess it's one of the quirks.
>
__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___