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

[amibroker] Re: Help with Fput and fopen in exploration



PureBytes Links

Trading Reference Links

One issue you have with this is knowing how many days your exploration
covers. Not sure if that information is available from the settings or
not.

For the sake of demonstration though, say you're only interested in
results for the most recent bar (ie. an exploration over 'n' last days
where 'n' = 1), then you can use something like this (this is generic,
not your specific case):

if (LastValue(Filter)) {
    fh = fopen("c:\\test\\test.csv", "a");
    fputs(Name() + StrFormat(", %1.3f, %1.3f\n", LastValue(Close),
LastValue(BuyPrice)), fh);
    fclose(fh);
    }

Opening the file with mode "a" will append each matching filter stock
to the file. This means though that every time you repeat the
exploration, the new results will append to whatever is there already.
You'll need to manually delete the file before running the exploration
if you want only the results from the one exploration.

If you want the exploration over more than the most-recent bar, you
can adjust the filter test here to cover more bars, but as I
mentioned, I'm not sure if this can be made automatic by reading the
exploration settings.

Regards,
GP


--- In amibroker@xxxxxxxxxxxxxxx, "jeremy7827110028" <jberkovits1@xxx>
wrote:
>
> I need to run several end of day explorations with a set naming 
> convention that must be archived for a research project.  Can I use 
> the fopen and Fputs commands with an exploration?
> 
> If the the fopen and fput is the correct method how do you output the 
> exploration results?  If the exploration code has several columns I 
> want exported to the csv file how do I loop through the exploration 
> results with the fput statement? 
> 
> The exploration code is:
> Filter = C > 50;
> Shares = round(50000/ Close);
> AddTextColumn(Name()+ " US","Security ID");
> AddColumn( DateTime(), "Filing Date", formatDateTime ); 
> AddColumn(Shares,"Size",1);
> AddColumn(Close,"Cost",1.2);
> 
> Yea  = Year();
> Mon  = Month();
> Daz = Day();
> Dh  = StrFormat("%02.0f%02.0f%02.0f", Mon, Daz, Yea );
> fh = fopen( "E:\\Exploration_Archive\\"+"TKRS_"+Dh+".csv", "w");
> 
> The naming convention for the fopen statement worked. That was as far 
> as I was able to get with my limited programming skills.    
> Any advice or assistance is appreciated.
>




Please note that this group is for discussion between users only.

To get 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
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/