Search the web
Sign In
New User? Sign Up
amibroker · AmiBroker User's List
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Looping or optimizing a set of non sequential numbers?   Message List  
Reply | Forward Message #132241 of 143808 |
Re: Looping or optimizing a set of non sequential numbers?

Thanks, Steve. That is a useful idea.

But let's say I had thousands of such numbers. Rather than setting
each number manually to an array item, is there a way to perhaps dump
the numbers into a batch file or something? And then somehow pull from
that file?

As a last resort, I could hand code it. But if there is a way to do it
in a more automated fashion, that would be best, as I anticipate
having to do this many times during different optimizations.


--- In amibroker@yahoogroups.com, "Steve Davis" <_sdavis@...> wrote:
>
> If the number of conditions is less than BarCount, you could store
> your non-sequential numbers in an array and then fetch them from the
> array later. Like this:
>
> // Store my numbers
> array[0] = 65;
> array[1] = 126;
> array[2] = 867;
> array[3] = 1023;
>
> // Iterate over my numbers
> for (i = 0; i <= 3; i++)
> number = array[i];
>
> Does that help?
> -Steve
>
>
> --- In amibroker@yahoogroups.com, "ozzyapeman" <zoopfree@> wrote:
> >
> > Looping and optimizing a set of sequential numbers is easy. But
how does
> > one loop or optimize through a large set of non sequential
numbers, that
> > have no defined step value or relation?
> >
> > Without getting too bogged down in tangential details, I have a
DLL that
> > created a new function in AmiBroker. That function spits out thousands
> > of possible buy/sell conditions. Those conditions were then
optimized in
> > a separate AFL, and I ended up with hundreds of "good" conditions
that I
> > now want to step through, for backtesting purposes.
> >
> > For e.g.:
> >
> > for (a = step through all the numbers below)
> >
> > condition65 = ...stuff
> > condition126 = ...stuff
> > condition867 = ...stuff
> > condition 1023 = ...stuff
> >
> > [... a few hundred more]
> >
> > Buy = VarGet("condition"+NumToStr(a,1.0,0));
> >
>





Fri Nov 21, 2008 4:34 pm

ozzyapeman
Offline Offline
Send Email Send Email

Forward
Message #132241 of 143808 |
Expand Messages Author Sort by Date

Looping and optimizing a set of sequential numbers is easy. But how does one loop or optimize through a large set of non sequential numbers, that have no...
ozzyapeman
Offline Send Email
Nov 21, 2008
2:48 am

If the number of conditions is less than BarCount, you could store your non-sequential numbers in an array and then fetch them from the array later. Like this:...
Steve Davis
_sdavis
Offline Send Email
Nov 21, 2008
5:54 am

Thanks, Steve. That is a useful idea. But let's say I had thousands of such numbers. Rather than setting each number manually to an array item, is there a way...
ozzyapeman
Offline Send Email
Nov 21, 2008
4:34 pm

... Unless I'm not entirely clear on your issue, it should be possible for your DLL to generate an AFL include file that contains all of your conditions? Then...
tuzo_wilson
Offline Send Email
Nov 21, 2008
4:44 pm

Re: [amibroker] Re: Looping or optimizing a set of non sequential numbers? Simply write them to an include file. herman...
Herman
psytek2
Offline Send Email
Nov 21, 2008
4:52 pm

When you say include file, does that only encompass other AFLs? Or could it also include a generic csv file? If it is only other AFLs, which it appears to be...
ozzyapeman
Offline Send Email
Nov 21, 2008
5:42 pm

You are presumably generating the "stuff" code somewhere, right? e.g. condition65 = ...stuff; condition126 = ...stuff; Thus, they are simply suggesting that...
Mike
sfclimbers
Offline Send Email
Nov 21, 2008
11:18 pm

Thanks Mike! I was dealing with the latter case. So your file operations code looks like it might do the trick. I will test this out....
ozzyapeman
Offline Send Email
Nov 22, 2008
2:54 am

You might notice a slowdown in the optimization performance if you read the numbers from a file hundreds of times during the optimization. If the performance...
Steve Davis
_sdavis
Offline Send Email
Nov 22, 2008
3:56 am

Thanks Steve. That also gives me a lot to try out. ... same ... (untested). ... dramatically slow ... or is...
ozzyapeman
Offline Send Email
Nov 22, 2008
5:28 am

Hey Mike (or anyone), As a simple test, I am first trying to extract a few numbers from a basic text file and print them to the interpretation window. But I'm ...
ozzyapeman
Offline Send Email
Nov 23, 2008
6:01 am

... You have incremented count twice so when you output the text you are outputting the value of an array item that has not be assigned to yet. Your printf...
tuzo_wilson
Offline Send Email
Nov 23, 2008
6:20 am

Thanks on the Count++. It's an improvement. But I still get wrong results: Number: 5.30979e-037 Number: 0 Number: 0 Number: 0 Number: 0 Number: 0 Number: 0 ...
ozzyapeman
Offline Send Email
Nov 23, 2008
7:30 am

... results: Oops...don't increment before writing out your data: good[count] = StrToNum(fgets(fh)); printf("Number: %g\n", good[count] ); count++; That should...
tuzo_wilson
Offline Send Email
Nov 23, 2008
8:36 am

Thanks! That finally works. One follow-up question on these printf special characters, like "%g\n". Where can I find more info on these? The AmiBroker help...
ozzyapeman
Offline Send Email
Nov 23, 2008
7:48 pm

Hi, Sorry for the absence. Looks like others have helped you out. As for your last question, the %g is as described in the link provided by AB. The \n is not...
Mike
sfclimbers
Offline Send Email
Nov 24, 2008
4:49 am

Hey Guys, Hoping anyone can still chime in on this problem. I got the following code to work. However, if my text file contains, say, 5,000 numbers (each on a...
ozzyapeman
Offline Send Email
Nov 25, 2008
5:47 am

Re: [amibroker] Re: Looping or optimizing a set of non sequential numbers? I don't see any fclose()... you must close the file after access. herman ... Hey...
Herman
psytek2
Offline Send Email
Nov 25, 2008
9:41 am

Thanks Herman but the problem persists. Here is a simplified version without the optimize. Only 2348 values are being read and printed to screen, out of a...
ozzyapeman
Offline Send Email
Nov 25, 2008
5:32 pm

Re: [amibroker] Re: Looping or optimizing a set of non sequential numbers? It looks like you are storing the values in a subscripted array. Such arrays can...
Herman
psytek2
Offline Send Email
Nov 25, 2008
6:06 pm

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...
ozzyapeman
Offline Send Email
Nov 25, 2008
6:16 pm

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...
ozzyapeman
Offline Send Email
Nov 25, 2008
6:21 pm

Re: [amibroker] Re: Looping or optimizing a set of non sequential numbers? I had to write some code to try for myself, it work fine in an indicator : if (...
Herman
psytek2
Offline Send Email
Nov 25, 2008
8:30 pm

Herman, Thanks for the code. I know I must be a bit dense, but how do I get it to work? I pasted your code into the AFL editor, clicked on 'Apply Indicator'. A...
ozzyapeman
Offline Send Email
Nov 25, 2008
8:47 pm

..and when I create a blank file myself with the specified name, it does not get filled with values after applying the indicator in Amibroker....
ozzyapeman
Offline Send Email
Nov 25, 2008
8:49 pm

Re: [amibroker] Re: Looping or optimizing a set of non sequential numbers? Open View->Log to see everything happening. Just open the Param window and click...
Herman
psytek2
Offline Send Email
Nov 25, 2008
9:45 pm

That works now. But strange that it only works as an indicator with parameters. I will fool around with the code some more to see if I can get it to work with...
ozzyapeman
Offline Send Email
Nov 25, 2008
10:31 pm

... Just FYI, I've run your code sample with StaticVarSet/Get in AA and it works fine. I am able to read in a 6000+ line file. The only changes I made was to...
tuzo_wilson
Offline Send Email
Nov 26, 2008
12:32 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help