Cool! Thanks Herman.

PS to imresident: 

Don't forget to include the Name() and BarIndex (sbi) in your Varname as in
the code I sent. Otherwise you won't have different trades for different
symbols. 

CAUTION: Oddball symbol names may not be compatible with Windows naming
conventions; I.e., using illegal characters such as starting the name with a
period.
--
Terry

-----Original Message-----
From: amibroker@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf
Of Herman
Sent: Sunday, January 21, 2007 16:06
To: imresident2001
Subject: Re: [amibroker] Re: Little help Flagging date a stock is purchased
on the chart

Hello imresident2001,

Sunday, January 21, 2007, 5:55:54 PM, you wrote:

> Thankyou for sharing that code Terry. Thats so much better than what i
> had in mind. The only negative is all the trades are lost when you
> close amibroker. Can some one pleas figure out a way to save the
> trades please. 

You can create/use PersistentVariables as shown below, they will save
data indefinitely until deleted. To save numbers you convert them to a
string first and pass the string to the function,
for example: String = numtostr(Number,1.2);


PersistentPath = "C:\\Program Files\\AmiBroker\\PersistentVariables\\";

function PersistentVarSetText( VarName, String )
        {
        global PersistentPath;
        fh = fopen( PersistentPath+VarName+".pva","w" );
        if( fh )
                {
                fputs( String, fh );
                fclose( fh );
                }
        return fh;
        }

function PersistentVarGetText( VarName )
        {
        global PersistentPath;
        fh = fopen( PersistentPath+VarName+".pva","r" );
        if( fh )
                {
                String = fgets( fh );
                fclose( fh );
                }
        else string = "";
        return String;
        } 

Reply via email to