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

[amibroker] Re: heikin-ashi



PureBytes Links

Trading Reference Links









Hi,

 

First, please write 2 text files on drive
A with NotePad – names 1.txt and 2.txt.

This  prog will create 3.txt on drive
A:

 

<font size=1 color=black
face="Courier New">       fhw = <font
size=1 color=blue face="Courier New">fopen<font size=1 color=black
face="Courier New">( <span
>"A:\3.txt"<font
size=1 color=black face="Courier New">, <font size=1 color=fuchsia
face="Courier New">"w"<font size=1 color=black
face="Courier New">); 

<font size=1 color=black
face="Courier New">       <font
size=1 color=maroon face="Courier New">if<font size=1
color=black face="Courier New">( fhw ) 

<font size=1 color=black
face="Courier New">       {

<font size=1 color=black
face="Courier New">              <font
size=1 color=blue face="Courier New">printf<font size=1 color=black
face="Courier New">(<span
>"File Opened
for writing"<span
>); 

<font size=1 color=black
face="Courier New">       } 

<font size=1 color=black
face="Courier New">       <font
size=1 color=maroon face="Courier New">else<font
size=1 color=black face="Courier New"> 

<font size=1 color=black
face="Courier New">       { 

<font size=1 color=black
face="Courier New">       <font size=1
color=blue face="Courier New">printf<span
>(<font
size=1 color=fuchsia face="Courier New">"Error opening file 3.txt for
writing"<span
>); 

<font size=1 color=black
face="Courier New">       } 

<font size=1 color=black
face="Courier New"> 

<font size=1 color=black
face="Courier New"> 

<font size=1 color=black
face="Courier New">       fhr1= <font
size=1 color=blue face="Courier New">fopen<font size=1 color=black
face="Courier New">( <span
>"A:\1.txt"<font
size=1 color=black face="Courier New">, <font size=1 color=fuchsia
face="Courier New">"r"<font size=1 color=black
face="Courier New">); 

<font size=1 color=black
face="Courier New">       <font
size=1 color=maroon face="Courier New">if<font size=1
color=black face="Courier New">( fhr1 ) 

<font size=1 color=black
face="Courier New">       { 

<font size=1 color=black
face="Courier New">              <font
size=1 color=maroon face="Courier New">while<font
size=1 color=black face="Courier New">( ! <font size=1 color=blue
face="Courier New">feof<span
>( fhr1 ) ) 

<font size=1 color=black
face="Courier New">              {


<font size=1 color=black
face="Courier New">               
             <font
size=1 color=blue face="Courier New">fputs<font size=1 color=black
face="Courier New">(<span
>fgets<font
size=1 color=black face="Courier New">( fhr1 ), fhw);

<font size=1 color=black
face="Courier New">                            
                                           

<font size=1 color=black
face="Courier New">              }


<font size=1 color=black
face="Courier New">       } 

<font size=1 color=black
face="Courier New">       <font
size=1 color=maroon face="Courier New">else<font
size=1 color=black face="Courier New"> 

<font size=1 color=black
face="Courier New">       { 

<font size=1 color=black
face="Courier New">       <font size=1
color=blue face="Courier New">printf<span
>(<font
size=1 color=fuchsia face="Courier New">"ERROR: file 1.txt can not be
found (does not exist)"<font size=1 color=black
face="Courier New">); 

<font size=1 color=black
face="Courier New">       } 

<font size=1 color=black
face="Courier New">       <font size=1
color=blue face="Courier New">fclose<span
>(fhr1);

<font size=1 color=black
face="Courier New"> 

<font size=1 color=black
face="Courier New">       fhr2= <font
size=1 color=blue face="Courier New">fopen<font size=1 color=black
face="Courier New">( <span
>"A:\2.txt"<font
size=1 color=black face="Courier New">, <font size=1 color=fuchsia
face="Courier New">"r"<font size=1 color=black
face="Courier New">); 

<font size=1 color=black
face="Courier New">       <font
size=1 color=maroon face="Courier New">if<font size=1
color=black face="Courier New">( fhr2 ) 

<font size=1 color=black
face="Courier New">       { 

<font size=1 color=black
face="Courier New">              <font
size=1 color=maroon face="Courier New">while<font
size=1 color=black face="Courier New">( ! <font size=1 color=blue
face="Courier New">feof<span
>( fhr2 ) ) 

<font size=1 color=black
face="Courier New">              {


<font size=1 color=black
face="Courier New">               
             <font
size=1 color=blue face="Courier New">fputs<font size=1 color=black
face="Courier New">(<span
>fgets<font
size=1 color=black face="Courier New">( fhr2 ), fhw);

<font size=1 color=black
face="Courier New">                            
                                           

<font size=1 color=black
face="Courier New">              }


<font size=1 color=black
face="Courier New">       } 

<font size=1 color=black
face="Courier New">       <font
size=1 color=maroon face="Courier New">else<font
size=1 color=black face="Courier New"> 

<font size=1 color=black
face="Courier New">       { 

<font size=1 color=black
face="Courier New">       <font size=1
color=blue face="Courier New">printf<span
>(<font
size=1 color=fuchsia face="Courier New">"ERROR: file 2.txt can not be
found (does not exist)"<font size=1 color=black
face="Courier New">); 

<font size=1 color=black
face="Courier New">       } 

<font size=1 color=black
face="Courier New">       <font size=1
color=blue face="Courier New">fclose<span
>(fhr2);

<font size=1 color=black
face="Courier New">       <font size=1
color=blue face="Courier New">fclose<span
>(fhw);

<font size=1 color=black
face="Courier New"> 

<font size=1 color=black
face="Courier New"> 

<font size=1 color=black
face="Courier New">Buy<font size=1 color=black
face="Courier New">=Sell=<font
size=1 color=fuchsia face="Courier New">0<font size=1
color=black face="Courier New">;

 

 

You should press BackTest and cancel BackTest
 several seconds later to avoid duplication.

 

Cheers,

Gedi



<font size=3
face="Times New Roman">





Graham [mailto:gkavanagh@xxxxxxxxxxxxx] 
[amibroker] Write and read data to files



 

I have my
eod and intraday data in separate databases (actually separate installations)
and wanted to have some explore results from the eod available for the intraday
to provide alert signals. Previously I would copy the oed results to excel,
then compile the results into lines and paste to the alert file as long lines
of data. I hoped to stop needing all the copy/pasting and make life easier for
myself.


I have managed to do this but it does sometimes freeze up during the intraday
auto scan. I think this has something to do with the reading of the data files
and maybe filling up the memory cache, but am not sure what the problem is or
how to get around it. The formula for storing the data into files and reading
the data are below. For simplicity sake I have changed the data to simple HHV
and LLV as the actual results are from an included file that is about 300 lines
long. 

The
stored data is in individual files of 2 per stock. Rxxx.txt for reslevel and Sxxx.txt
for suplevel. (xxx = ticker name) I tried to<span
> make all in one file but could not get
it to work.

If someone can give me help with the freezing problem and how to
have all the information in a single file it would be appreciated.<span
>

/*

Export support/resistance data to TXT files 

One file for each stock

In the first line insert the directory you want to save them to,
make sure the directory exists

Select your charts to export with the "Apply to" filter
in AA window 

Select the timeframe period using the AA "Settings"
"n=1"

Press Scan or Explore button

by Graham Kavanagh 17 Feb 2004

*/

//#pragma nocache

//#include "C:\Program Files\AmiBroker\AFL Turning Points
DWM\Trend Identification.afl"

DailyTPTopPrice
= HHV(<font
color=red>H,<font
color=fuchsia>5);

DailyTPBotPrice
= LLV(<font
color=red>L,<font
color=fuchsia>5);

fres = <font
color=blue>fopen( <font
color=darkred>"C:\\Program
Files\\AmiBroker\\SupResData\\R"+<span
>Name()+<font
color=darkred>".txt",
"w");


<span
>if<font
size=2>( fres ) 

{ 

fputs<span
>( StrFormat(<span
>"%.4f\n",
DailyTPTopPrice), fres );

fclose<span
>( fres ); 

} 

fsup = <font
color=blue>fopen( <font
color=darkred>"C:\\Program
Files\\AmiBroker\\SupResData\\S"+<span
>Name()+<font
color=darkred>".txt",
"w");


<span
>if<font
size=2>( fsup ) 

{ 

fputs<span
>( StrFormat(<span
>"%.4f\n",
DailyTPBotPrice), fres );

fclose<span
>( fsup ); 

} 

Buy<span
> = 0; 

Filter<span
>=1;

AddColumn<span
>(DailyTPBotPrice,<span
>"",<font
color=fuchsia>1.3);

AddColumn<span
>(DailyTPTopPrice,<span
>"",<font
color=fuchsia>1.3);

//===================%<-----------------------------------//<font
size=2>

/*

Import support/resistance data from TXT files 

One file for each stock

In the first line insert the directory they are stored, make sure
the files exist

Select your charts to export with the "Apply to" filter
in AA window 

Select the timeframe period using the AA "Settings"
"n=1"

Press Scan

by Graham Kavanagh 17 Feb 2004

*/

Sup = <font
color=blue>fopen( <font
color=darkred>"C:\\Program
Files\\AmiBroker\\SupResData\\S"+<span
>Name()+<font
color=darkred>".txt",
"r");


SupLevel
= StrToNum(<font
color=blue>fgets(Sup));

Res = <font
color=blue>fopen( <font
color=darkred>"C:\\Program
Files\\AmiBroker\\SupResData\\R"+<span
>Name()+<font
color=darkred>".txt",
"r");


ResLevel
= StrToNum(<font
color=blue>fgets(Res));

Filter<span
>=1;

AddColumn<span
>(SupLevel, <span
>"support",<font
color=fuchsia>1.3
);

AddColumn<span
>(ResLevel, <span
>"resist",<font
color=fuchsia>1.3
);

BuySig = <font
color=blue>Cross(<font
color=red>C,ResLevel);

SellSig =
Cross(SupLevel,<font
color=red>C);

Buy<span
> = BuySig;

Sell<span
> = SellSig;

AlertIf<span
>( Buy, <span
>"", <font
color=darkred>"B"
+ ResLevel, 1,
1+<font
color=fuchsia>2+<font
color=fuchsia>4+<font
color=fuchsia>8,
1
);

AlertIf<span
>( Sell, <span
>"", <font
color=darkred>"S"
+ SupLevel, 1,
1+<font
color=fuchsia>2+<font
color=fuchsia>4+<font
color=fuchsia>8,
1
);



Cheers,
Graham
http://e-wire.net.au/~eb_kavan/




Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<font size=2
face="Courier New">
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx 
(Web page: <a
href="">http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: <a
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.