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

[amibroker] Re: Intraday data importing from myFile.txt



PureBytes Links

Trading Reference Links

Hermann,

very nice explanation of Osaka plugin, it is not absolutely obvious 
to use and I hope your code will help me (and us).

stephane

> Here is my first attempt at using the OSAKA DLL to solve some of 
the current
> problems discussed on the list. The OSAKA DLL turns out to be very 
powerful
> and pretty fast too. Many thanks to Joe Osaka, for contributing 
this nice
> DLL!
> I show only three functions to see what interest there is on the 
list.
> Typical tasks that can be performed by the thre functions are:
>   a.. save optimized parameters (numbers, not arrays) for 
individual stocks
> during in-line optimizations,  Typical parameters saved for each 
stock might
> be a RSI Period, LongThreshold, ShortThreshold, ProfitStop and 
StopLoss.
>   b.. simulate Static variables that can be accessed while 
performing
> various AA operations, simply save the parameters under a variable 
name of
> your choice.
>   c.. create/save Ranking related data for stocks, whatever you 
like to have
> in a table for Excel analysis and recall.
>   d.. dynamic Watchlists, i.e. enable stocks on the basis of their 
being
> consituent in an Index. You could Explore all annual lists to built 
a master
> table for all stocks ever traded in the index and save the start-
trading and
> stop trading dates for each stock. When backtesting you use this 
data to
> enable trading the stock or not. To do this properly this must be 
done using
> the PositionScore, perhaps set a very High scrore for Short 
positions and a
> very Low score for Long positions to disable stocks. That way they 
will be
> skipped but your portfolio keeps trading the same number of stocks.
>   e.. You could probably use the functions to develop code to skip
> top-ranked stocks .... but i haven't tried it.
> There is no limit to the number of parameter-sets that can be 
saved. To use
> the functions you must copy the ParameterTableInclude001.afl 
program listed
> below to your Include Directory. The functions are designed for 
ease of use,
> not for speed. For more complicated tasks and better speed you 
should learn
> to call the OSAKA functions directly. To use multiple tables just 
substitute
> other names for "ParamaterTable"
> 
> 1) SaveParameters( "Name", Number1, Number2, Number3, Number4, 
Number5 );
> This function saves 5 different parameters under one name in a 
binary file
variable
> name, or a dynamically created name. If you set one or more numbers 
to NULL
> then that particular number will not change in the table and the 
previous
> value will remain valid. The length of the name is limited to 30 
char.
> 
> 2) P=GetParameters( "Name" );
> The function returns an array; the parameters are stored in 
elements1-5. To
> use the variables under their original names you would use P1=O[1]; 
P2=P[2];
> P3=P[3]; P4=P[4]; and P5=P[5]; I reserved P[0] for other uses.
> 
> 3) OutputParameterTable( Flag );
> Flag = 0 dumps the parameter table to the interpretation window 
from an
> indicator or using the Equity button in the AA.
> Flag = 1 use the Explorer to display the table contents for the 
stocks in
> the current Watchlist, does not list names not in the Watchlist.
> Flag = 2 creates a ParameterTable.csv file in the AmiBroker 
directory for
> import into Excel.
> 
> For a quick test:
> 
> 1) Copy the Include file to your Include Directory and load the 
code in your
> AA, select a Watch list, set a range, and Run the OldBacktester, 
click
> Equity to run the formula as an Indicator to display the table in 
your
> interpretation window. Note that the current stock, if it is not in 
your
> Watchlist, is still included in your ParameterTable. I do almost 
all my
> system/indicator development from the AA window but the functions 
should
> work from anywhere in AmiBroker.
> 
> 2) Run the Exporer on you Watchlist to display all variable save 
for it's
> membership.
> 
> 3) Run Excel and import the ParameterTable.csv file.
> 
> have fun!
> herman
> 
> 
> --------------------------------------------------------------------
--------
> ----
> 
> 
> // Test program for the OSAKA parameter functions
> Buy=Sell=Short=Cover=0;
> Filter = Status("LastBarInRange"); // Or set n-Last-Quotations to 1
> #include <ParameterTableInclude001.afl>
> 
> // Create some dummy data...
> T1=Status("StockNum");
> T2=LastValue(DateNum());
> T3=BarCount;
> T4=LastValue(Random());
> T5=12345;
> 
> SaveParameters( Name(), T1, T2, T3, T4, T5 );    // Save 5 
parameters under
> ticker
> SaveParameters( Name(), T1, Null, T3, Null, T5 );// Update only 3 
of them
> SaveParameters( "Test1", 1,2,3,4,5);      // Save an arbitrary 
variable
> OutputParameterTable(1|2|4);          // Review table in various 
formats
> P=GetParameters( Name() );         // Read ticker parameters from 
table
> T=GetParameters("Test1");         // Read arbitrary variable from 
table
> 
> 
> 
> --------------------------------------------------------------------
--------
> ----
> 
> 
> // ParameterTableInclude001.afl --- Copy this file to your 
AmiBroker Include
> Directory
> 
> osInitialize();
> 
> function SaveParameters( Ticker, P1, P2,P3,P4,P5 )
>    {
>    global ParameterTable;
>    local RowCount, TickerRow, Row, P1, P2, P3, P4, P5;
>    ParameterTable = osTabCreate();
>       {
>       osTabAddColumn( "Symbol", 2, ParameterTable,  30 );
>       osTabAddColumn( "P1", 1, ParameterTable );
>       osTabAddColumn( "P2", 1, ParameterTable );
>       osTabAddColumn( "P3", 1, ParameterTable );
>       osTabAddColumn( "P4", 1, ParameterTable );
>       osTabAddColumn( "P5", 1, ParameterTable );
>       }
>    RowCount = osTabGetRowCount( ParameterTable );
>    TickerRow = -1;
>    for( Row = 0; Row <= RowCount; Row++ )
>       {
>       if( Ticker == osTabGet( Row, 0,  ParameterTable )) TickerRow 
= Row;
>       }
>    if(TickerRow < 0)
>       Row=RowCount;
>    else
>       Row = TickerRow;
>    osTabSetString( Ticker, Row, 0, ParameterTable );
>    if(Nz(P1,0)==P1)    osTabSetNumber( P1, Row, 1, ParameterTable );
>    if(Nz(P2,0)==P2)    osTabSetNumber( P2, Row, 2, ParameterTable );
>    if(Nz(P3,0)==P3)    osTabSetNumber( P3, Row, 3, ParameterTable );
>    if(Nz(P4,0)==P4)    osTabSetNumber( P4, Row, 4, ParameterTable );
>    if(Nz(P5,0)==P5)    osTabSetNumber( P5, Row, 5, ParameterTable );
>    osTabDelete( ParameterTable );
>    }
> 
> function OutputParameterTable( Destination )
>    {
>    local Row, RowCount, NOTable, Destination, OutPut;
>    global ParameterTable;
>    ParameterTable = osTabCreate();
>       RowCount = osTabGetRowCount( ParameterTable );
>    OutPut = "";
>    if( Destination & 1  ) // To Interpretation window
>       {
>       for( Row = 0; Row < RowCount; Row++ )
>          {
>          OutPut = OutPut +
>          osTabGet( Row, 0,  ParameterTable )+", "+
>          osTabGet( Row, 1,  ParameterTable )+", "+
>          osTabGet( Row, 2,  ParameterTable )+", "+
>          osTabGet( Row, 3,  ParameterTable )+", "+
>          osTabGet( Row, 4,  ParameterTable )+", "+
>          osTabGet( Row, 5,  ParameterTable )+"\n";
>          }
>       }
> 
>    if( Destination & 2  ) // To Exploration Results window
>       {
>       SetOption("NoDefaultColumns",True);
>       TickerRow = -1;
>       for( Row = 0; Row < osTabGetRowCount( ParameterTable ); 
Row++ )
>          if( Name() == osTabGet( Row, 0,  ParameterTable )) 
TickerRow = Row;
>       if(TickerRow >= 0 )
>       AddTextColumn(
>              osTabGet( TickerRow, 0,  
ParameterTable),"WLTicker",1.0);
>       AddColumn(osTabGet( TickerRow, 1,  
ParameterTable ),"Par1",1.4);
>       AddColumn(osTabGet( TickerRow, 2,  
ParameterTable ),"Par2",1.4);
>       AddColumn(osTabGet( TickerRow, 3,  
ParameterTable ),"Par3",1.4);
>       AddColumn(osTabGet( TickerRow, 4,  
ParameterTable ),"Par4",1.4);
>       AddColumn(osTabGet( TickerRow, 5,  
ParameterTable ),"Par5",1.4);
>       }
> 
>    if(Destination & 4 ) // To csv file
>       {
>       osTabExport( "ParameterTable.csv", ",", ParameterTable);
>       }
>    return Output;
>    }
> 
> function GetParameters( Ticker )
>    {
>    local Row, RowCount, NOTable, Destination, OutPut, TickerRow;
>    global ParameterTable;
>    ParameterTable = osTabCreate();
>    Parameter[0] = -1; // First Element is used to pass table status
>       {
>       ParameterArray = 0;
>       RowCount = osTabGetRowCount( ParameterTable );
>       for( Row = 0; Row < osTabGetRowCount( ParameterTable ); 
Row++ )
>          if( Name() == osTabGet( Row, 0,  ParameterTable )) 
TickerRow = Row;
>       ParameterArray[1] = osTabGet( TickerRow, 1 , ParameterTable );
>       ParameterArray[2] = osTabGet( TickerRow, 2 , ParameterTable );
>       ParameterArray[3] = osTabGet( TickerRow, 3 , ParameterTable );
>       ParameterArray[4] = osTabGet( TickerRow, 4 , ParameterTable );
>       ParameterArray[5] = osTabGet( TickerRow, 5 , ParameterTable );
>       }
>    return ParameterArray;
>    }


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 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
---------------------------------------------------------------------~->

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/