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

RE: [amibroker] AB's right margin



PureBytes Links

Trading Reference Links

As will I! Nice coding dingo, and thanks!

Dan

--- In amibroker@xxxxxxxxxxxxxxx, "Herman van den Bergen" 
<psytek@xxxx> wrote:
> Very nice d, great job!
> 
> I'll be using it every day :-)
> 
> herman.
>   -----Original Message-----
>   From: dingo [mailto:dingo@x...]
>   Sent: Saturday, April 17, 2004 2:26 PM
>   To: amibroker@xxxxxxxxxxxxxxx
>   Subject: RE: [amibroker] Multiple file Import
> 
> 
>   EOD Export To AFL is a separate file that will export the quotes 
from the
> EOD database:
> 
>   One thing I left out of the notes is that you need to have an 
instance of
> Amibroker running before you run the script. It doesn't matter what 
database
> it's pointing to as that will be set by the script.
> 
>   Here is the AFL formula:
> 
>   Buy=Sell=Short=Cover=0;
>   Filter=Status("LastBarInTest");
>   // The following code exports quotes of current stock to 
quotes.csv comma
> separated file
>   Path = "C:\\Program Files\\AmiBroker\\Output\\";
>   fh = fopen( Path+Name()+"-EOD.csv", "w");
>   if( fh )
>           {
>   //      fputs( "Date,Open,High,Low,Close,Volume\n", fh );
> 
>           y = Year();
>           m = Month();
>           d = Day();
> 
>           for( i = 0; i < BarCount; i++ )
>                   {
>                   ds = StrFormat("%02.0f-%02.0f-%02.0f,", y[ i ], m
[ i ],
> d[ i ] );
>                   fputs( ds, fh );
> 
>                   qs = StrFormat("%.4f, %.4f, %.4f, %.4f, %.0f\n", O
[ i ],
> H[ i ], L[ i ], C[ i ], V[ i ] );
>                   fputs( qs, fh );
>                   }
>           fclose( fh );
>           }
> 
> 
> 
>     d
> 
> 
> --------------------------------------------------------------------
--------
> 
>     From: Prashanth [mailto:prash454@x...]
>     Sent: Saturday, April 17, 2004 1:56 PM
>     To: amibroker@xxxxxxxxxxxxxxx
>     Subject: Re: [amibroker] Multiple file Import
> 
> 
>     Hi dingo,
> 
>     Thanks for the Code. A small query, in the code you have 
reffered to EOD
> Export.afl. What I want to know is should I save this file also as 
EOD
> Export.afl alongwith Export.vbs or is there any other file.
> 
>     Thanks
> 
>     Prashanth
>       ----- Original Message -----
>       From: dingo
>       To: amibroker@xxxxxxxxxxxxxxx
>       Sent: Saturday, April 17, 2004 9:05 PM
>       Subject: RE: [amibroker] Multiple file Import
> 
> 
>       Just wanted to post the latest version - I've added a lot of 
comments
> that should help.
> 
>       '**************************************
>       'Purpose: Run A Procedure in Amibroker
>       '         that will export quotes from
>       '         one database into CSV files
>       '         and then import them into
>       '         another database.
>       '
>       'Operation: Name this file whatever you
>       '         wish but give it an extension
>       '         of vbs. Place it in your
>       '         Amibroker folder and run it
>       '         by double clicking on the file
>       '         name.
>       '
>       '         Make sure that you change those
>       '         lines under the !!!!!!! lines
>       '         to match your system.
>       '
>       '         Make sure that you have the
>       '         correct format file in the
>       '         format folder.
>       '
>       'The Code: Is written in VB Script and
>       '         runs within "Windows Scripting
>       '         Host (WSH)". I have included
>       '         many commented out msgbox lines
>       '         that you can uncomment if you're
>       '         having problems. That way you
>       '         have a way to monitor the progress
>       '         of the script as it executes.
>       '
>       'vbScript Help: The following links will
>       '         provide information on VBScript:
>       '         (Be careful of folded lines)
>       '
>       '
> http://msdn.microsoft.com/library/default.asp?url=/nhp/Defaultasp?
contentid=
> 28001169
>       '
>       '
> http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/script56/ht
> ml/vbscripttoc.asp
>       '
>       ' 
http://www.microsoft.com/technet/community/scriptcenter/default.mspx
>       '
>       ' http://groups.msn.com/windowsscript/_homepage.msnw?
pgmarket=en-us
>       '
>       'Created By: dingo
>       '**************************************
> 
>       Dim oAB
>       Dim oAA
>       Dim fso
>       Dim fldr
>       Dim fls
>       Dim fle
>       Dim flenam
>       Dim result
> 
>       dim RT_DB_Path
>       dim EOD_DB_Path
>       dim Frmla_Path
>       dim CSV_Dir
>       dim CSV_FleNam
>       dim FmtFleNam
> 
>       '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>       ' change the following paths to suit your configuration
>       '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>       RT_DB_Path = "C:\Program Files\Amibroker\Data"
>       EOD_DB_Path = "C:\Program Files\Amibroker\TC2000"
>       Frmla_Path = "C:\Program Files\Amibroker\AFL\EOD Export.Afl"
>       CSV_Dir = "C:\Program Files\Amibroker\Output"
>       FmtFleNam = "EOD_To_RT.Format"
> 
>       ' declare object for Amibroker and the file system object
>       set oAB = CreateObject("Broker.Application")
>       Set oAA = oAB.Analysis
>       set fso = CreateObject("Scripting.FileSystemObject")
> 
>       '------------------------------------------
>       ' Delete all csv files in the CSV folder
>       ' so that we don't import any old ones
>       ' that may still be there
>       '------------------------------------------
>       'wscript.echo "Cleaning Out " + CSV_Dir
>       '------------------------------------------
>       ' set the folder object
>       '------------------------------------------
>       Set fldr = fso.GetFolder(CSV_Dir)
>       '------------------------------------------
>       ' set the files object
>       '------------------------------------------
>       Set fls  = fldr.Files
>       For Each fle in fls
>           flenam = fle.name
>           '------------------------------------------
>           ' make sure its a csv file
>           '------------------------------------------
>           if right(ucase(flenam), 4) = ".CSV" then
>               '------------------------------------------
>               ' Delete this old file
>               '------------------------------------------
>               fle.Delete
>           end if
>       Next
>       '------------------------------------------
>       ' destroy the folder and file objects
>       '------------------------------------------
>       set fle = nothing
>       set fls = nothing
> 
>       '------------------------------------------
>       ' Set from and to dates, and the watchlist
>       '------------------------------------------
>       with oAA
>           '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>           ' change the following settings to suit your configuration
>           '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
>           .RangeMode = 3
>           .RangeFromDate = "01/01/2001"
>           .RangeToDate = "12/31/2002"
>           .ClearFilters
>           .ApplyTo = 2
>           .Filter(0, "watchlist") = 29
>       end with
> 
>       '------------------------------------------
>       ' The following is the "main" code for the
>       ' exporting and importing of the data
>       '------------------------------------------
>       ' Load EOD Data Base
>       '------------------------------------------
>       'wscript.echo "Loading EOD Database: " + EOD_DB_Path
>       If oAB.LoadDatabase(cstr(EOD_DB_Path)) Then
>           '------------------------------------------
>           ' Load the AFL for Building the CSV File
>           '------------------------------------------
>           'wscript.echo "Loading AFL: " + Frmla_Path
>           if oAA.LoadFormula(cstr(Frmla_Path)) Then
>               '------------------------------------------
>               ' Run The Scan
>               '------------------------------------------
>               'wscript.echo "Running Scan"
>               result = oAA.Scan
>               '------------------------------------------
>               ' now load the RT Database
>               '------------------------------------------
>               'wscript.echo "Loading RT Database: " + RT_DB_Path
>               If oAB.LoadDatabase(cstr(RT_DB_Path)) Then
>                   '------------------------------------------
>                   ' import each csv file in the EODexports folder
>                   ' set the files object
>                   '------------------------------------------
>                   Set fls  = fldr.Files
>                   For Each fle in fls
>                       flenam = fle.name
>                       '------------------------------------------
>                       ' make sure its a csv file
>                       '------------------------------------------
>                       if right(ucase(flenam), 4) = ".CSV" then
>                           '-----------------------------------------
-
>                           ' Import the CSV File using the correct 
format
>                           '-----------------------------------------
-
>                           CSV_FleNam = CSV_Dir + "\" + flenam
>                           'wscript.echo "Importing " + CSV_FleNam
>                           result = oAB.Import(0, cstr(CSV_FleNam),
> cstr(FmtFleNam))
>                           if result <> 0 Then
>                               msgbox "Error Running Import"
>                               Exit For
>                           end if
>                       end if
>                   Next
>                   oAB.RefreshAll()
>                   'wscript.echo "Saving RT Database"
>                   oAB.SaveDataBase
>                   MsgBox "Finished"
>               Else
>                   msgbox "Can't Load RT Database"
>               End IF
>           else
>               msgbox "Can't Load EOD Export.Afl"
>           End If
>       Else
>           MsgBox "Cant Load EOD Database"
>       End If
> 
>       '------------------------------------------
>       ' destroy all objects
>       '------------------------------------------
>       set fle = nothing
>       set fls = nothing
>       set fldr = nothing
>       set fso = nothing
> 
>       Set oAA = Nothing
>       set oAB = nothing
> 
>       d



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com.  Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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:
     http://docs.yahoo.com/info/terms/