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

Re: [amibroker] NO WAY [Was]: New Variable Class



PureBytes Links

Trading Reference Links




Ken,
 
As for hints: you would do the following:
1. iterate through watch list and store scores (in case of 
osaka plugin osTabSetNumber)
2. find top ranked symbols (this can be done even entriely in 
AFL as Dimitris has shown,
or using Osaka plugin sort capability - osTabSort 
function)
3. create average from top ranked symbols. 
 
Below is the code that uses Osaka plugin 1.4. 
 

<P class=MsoNormal 
><SPAN lang=EN-US 
>osInitialize<SPAN 
lang=EN-US 
>();<?xml:namespace 
prefix = o ns = "urn:schemas-microsoft-com:office:office" 
/>
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>List 
= <SPAN lang=EN-US 
>GetCategorySymbols<SPAN 
lang=EN-US 
>(categoryGroup, 
<SPAN lang=EN-US 
>254<SPAN 
lang=EN-US 
> 
); <SPAN lang=EN-US 
>// 
<-- change wl number here<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
>table=<SPAN 
lang=EN-US 
>osTabCreate<SPAN 
lang=EN-US 
>();
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>// 
setup columns<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
>osTabAddColumn<SPAN 
lang=EN-US 
>( 
<SPAN lang=EN-US 
>"Ticker"<SPAN 
lang=EN-US 
>, 
<SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
>, 
table, <SPAN lang=EN-US 
>25<SPAN 
lang=EN-US 
> 
);
<P class=MsoNormal 
><SPAN lang=EN-US 
>for<SPAN 
lang=EN-US 
>( 
j = <SPAN lang=EN-US 
>0<SPAN 
lang=EN-US 
>; 
j < BarCount; j++ )
<P class=MsoNormal 
><SPAN lang=EN-US 
>{
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>  <SPAN lang=EN-US 
>osTabAddColumn<SPAN 
lang=EN-US 
>( 
<SPAN lang=EN-US 
>"Score"<SPAN 
lang=EN-US 
>+j, 
<SPAN lang=EN-US 
>1<SPAN 
lang=EN-US 
>, 
table );
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>  <SPAN lang=EN-US 
>osTabAddColumn<SPAN 
lang=EN-US 
>( 
<SPAN lang=EN-US 
>"Close"<SPAN 
lang=EN-US 
>+j, 
<SPAN lang=EN-US 
>1<SPAN 
lang=EN-US 
>, 
table );
<P class=MsoNormal 
><SPAN lang=EN-US 
>}
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>// 
CALCULATING SCORES and saving them to the table<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
>for<SPAN 
lang=EN-US 
>(i=<SPAN 
lang=EN-US 
>0<SPAN 
lang=EN-US 
>; 
( ticker = <SPAN lang=EN-US 
>StrExtract<SPAN 
lang=EN-US 
>( 
List, i ) ) != <SPAN lang=EN-US 
>""<SPAN 
lang=EN-US 
>; 
i++)
<P class=MsoNormal 
><SPAN lang=EN-US 
>{
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
> <SPAN lang=EN-US 
>SetForeign<SPAN 
lang=EN-US 
>(ticker);
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>  
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>  <SPAN lang=EN-US 
>osTabSetString<SPAN 
lang=EN-US 
>( 
ticker, i, <SPAN lang=EN-US 
>0<SPAN 
lang=EN-US 
>, 
table );
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>  
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
> score = <SPAN lang=EN-US 
>50<SPAN 
lang=EN-US 
>- 
<SPAN lang=EN-US 
>RSI<SPAN 
lang=EN-US 
>(); 
<SPAN lang=EN-US 
>// 
YOUR SCORE CALCULATION HERE !!!!<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
> <SPAN lang=EN-US 
>for<SPAN 
lang=EN-US 
>( 
j = <SPAN lang=EN-US 
>0<SPAN 
lang=EN-US 
>; 
j < BarCount; j++)
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
> {
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>   <SPAN lang=EN-US 
>osTabSetNumber<SPAN 
lang=EN-US 
>( 
<SPAN lang=EN-US 
>abs<SPAN 
lang=EN-US 
>( 
<SPAN lang=EN-US 
>Nz<SPAN 
lang=EN-US 
>( 
score[ j ] ) ), i, <SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
> 
* j + <SPAN lang=EN-US 
>1<SPAN 
lang=EN-US 
>, 
table );
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>   <SPAN lang=EN-US 
>osTabSetNumber<SPAN 
lang=EN-US 
>( 
Close[ j ], i, <SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
> 
* j + <SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
>, 
table ); <SPAN lang=EN-US 
>// 
for calculation of average<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
> }
<P class=MsoNormal 
><SPAN lang=EN-US 
>}
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>// 
you can export for debugging<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
>//osTabExport( 
"test.csv", ",", table );<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>// 
SORTING SCORES AND finding top ranks:<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
>average 
= <SPAN lang=EN-US 
>0<SPAN 
lang=EN-US 
>; 
<SPAN lang=EN-US 
>// 
init avarage<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>for<SPAN 
lang=EN-US 
>( 
j = <SPAN lang=EN-US 
>0<SPAN 
lang=EN-US 
>; 
j < BarCount; j++)
<P class=MsoNormal 
><SPAN lang=EN-US 
>{
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>   <SPAN lang=EN-US 
>osTabSort<SPAN 
lang=EN-US 
>( 
table, <SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
> 
* j + <SPAN lang=EN-US 
>1<SPAN 
lang=EN-US 
>, 
False );
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    average[ j ] = <SPAN 
lang=EN-US 
>0<SPAN 
lang=EN-US 
>;
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    topnum = <SPAN 
lang=EN-US 
>10<SPAN 
lang=EN-US 
>; 
<SPAN lang=EN-US 
>// 
change this iterate throgh other number than top-10<SPAN 
>  <SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    <SPAN lang=EN-US 
>for<SPAN 
lang=EN-US 
>( 
k = <SPAN lang=EN-US 
>0<SPAN 
lang=EN-US 
>; 
k < topnum ; k++ ) <SPAN lang=EN-US 
>// 
<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    {
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>       <SPAN 
>       fc = 
<SPAN lang=EN-US 
>osTabGet<SPAN 
lang=EN-US 
>( 
k, <SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
> 
* j + <SPAN lang=EN-US 
>2<SPAN 
lang=EN-US 
>, 
table ); 
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>       average[ j 
] = average[ j ] + fc;
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    }
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    average[ j ] = average[ j 
]/topnum; <SPAN lang=EN-US 
>// 
calculate average from top N symbols at given bar<SPAN lang=EN-US 
>
<P class=MsoNormal 
><SPAN lang=EN-US 
><SPAN 
>    
<P class=MsoNormal 
><SPAN lang=EN-US 
>}
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>osTabDelete<SPAN 
lang=EN-US 
>( 
table );
<P class=MsoNormal 
><SPAN lang=EN-US 
> 
<P class=MsoNormal 
><SPAN lang=EN-US 
>Filter<SPAN 
lang=EN-US 
>=<SPAN 
lang=EN-US 
>1<SPAN 
lang=EN-US 
>;
<P class=MsoNormal 
><SPAN lang=EN-US 
>AddColumn<SPAN 
lang=EN-US 
>(average, 
<SPAN lang=EN-US 
>"AVG 
top10 (each bar different)"<SPAN lang=EN-US 
> 
); 
<SPAN lang=EN-US 
>Plot<SPAN 
lang=EN-US 
>( 
average, <SPAN lang=EN-US 
>"AVG 
top10 (each bar different)"<SPAN lang=EN-US 
>, 
colorRed );

 
Best regards,Tomasz Janeczkoamibroker.com
----- Original Message ----- 
From: "Ken Close" <<A 
href="">closeks@xxxxxxxx<FONT 
size=2>>
To: <<A 
href=""><FONT 
size=2>amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, November 07, 2003 1:50 PM
Subject: RE: [amibroker] NO WAY [Was]: New Variable 
Class
Tomasz:Of course.  
As usual you are correct.  I knew it.  I am trying toprovoke/seek 
some more help (not do it for me but point me in the rightdirection with 
some hints/help).Ken-----Original Message-----From: 
Tomasz Janeczko [mailto:amibroker@xxxxxx] Sent: Friday, November 07, 2003 
7:39 AMTo: <FONT 
size=2>amibroker@xxxxxxxxxxxxxxxSubject: Re: 
[amibroker] NO WAY [Was]: New Variable ClassKen,There is a huge 
difference between:A. "not possible"B. "not possible by someone with my 
level of exprerience"Your problem falls under B.Telling that 
something is not possible in AFL is almost equivalentto saying that it is 
not possible to write it at all (in any language).Best 
regards,Tomasz Janeczkoamibroker.com----- Original Message ----- 
From: "Ken Close" <<FONT 
size=2>closeks@xxxxxxxx>To: <<A 
href=""><FONT 
size=2>amibroker@xxxxxxxxxxxxxxx>Sent: Friday, 
November 07, 2003 1:02 PMSubject: [amibroker] NO WAY [Was]: New Variable 
ClassDT:You said:"I like your expression "no way" 
!!I donīt like the same expression, when we talk AFL."I offer my 
opinion in a long message in the AB-Beta message list that Ihave a trading 
approach that AFL can not (NOT) handle.  Maybe usingcomplex script and 
intricate internal handling of tables, but not AFL.And not by someone with 
my level of experience.I do not know if you use the new Portfolio 
Backtester, nor if you havetime or interest in my plight/problem.But 
for now and as several others have advised me about my tradingsystem, "NO 
WAY" for AFL.Comment??Ken-----Original 
Message-----From: DIMITRIS TSOKAKIS [mailto:TSOKAKIS@xxxxxxxxx]Sent: 
Friday, November 07, 2003 4:21 AMTo: <A 
href=""><FONT 
size=2>amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] 
Re: New Variable ClassStephane,We have AddToComposite()[we 
should be happy...]We are not programmers [at least me][we should be 
also happy...]I like your expression "no way" !!I donīt like the same 
expression, when we talk AFL.I shall see it again [the weekend, not 
now...]As for the group of composites, they may be constructed all 
togetherwith a loop.Dimitris Tsokakis--- In <A 
href=""><FONT 
size=2>amibroker@xxxxxxxxxxxxxxx, "Stephane 
Carrasset"<<FONT 
size=2>nenapacwanfr@x...> wrote:> 
Dimitri,>> yes you're right,> no way to optimize directly 
in a composite...> we must create separatly each composite for each 
numeric value.>> stephane>Send BUG 
REPORTS to <FONT 
size=2>bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
<FONT 
size=2>suggest@xxxxxxxxxxxxx<FONT 
size=2>-----------------------------------------Post AmiQuote-related 
messages ONLY to: <FONT 
size=2>amiquote@xxxxxxxxxxxxxxx(Web page: <A 
href=""><FONT 
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT 
size=2>)--------------------------------------------Check group FAQ 
at:<A 
href=""><FONT 
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
size=2>Your use of Yahoo! Groups is subject to<A 
href=""><FONT 
size=2>http://docs.yahoo.com/info/terms/<FONT 
size=2>Send BUG REPORTS to <FONT 
size=2>bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
<FONT 
size=2>suggest@xxxxxxxxxxxxx<FONT 
size=2>-----------------------------------------Post AmiQuote-related 
messages ONLY to: <FONT 
size=2>amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href=""><FONT 
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT 
size=2>)--------------------------------------------Check group FAQ 
at:<A 
href=""><FONT 
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
size=2> Your use of Yahoo! Groups is subject to<A 
href=""><FONT 
size=2>http://docs.yahoo.com/info/terms/ 
------------------------ Yahoo! Groups Sponsor 
---------------------~-->Buy Ink Cartridges or Refill Kits for your HP, 
Epson, Canon or LexmarkPrinter at MyInks.com. Free s/h on orders $50 or more 
to the US & Canada.<A 
href=""><FONT 
size=2>http://www.c1tracking.com/l.asp?cid=5511<A 
href=""><FONT 
size=2>http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM<FONT 
size=2>---------------------------------------------------------------------~->Send 
BUG REPORTS to <FONT 
size=2>bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
<FONT 
size=2>suggest@xxxxxxxxxxxxx<FONT 
size=2>-----------------------------------------Post AmiQuote-related 
messages ONLY to: <FONT 
size=2>amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href=""><FONT 
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT 
size=2>)--------------------------------------------Check group FAQ at: 
<A 
href=""><FONT 
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT 
size=2> Your use of Yahoo! Groups is subject to <A 
href=""><FONT 
size=2>http://docs.yahoo.com/info/terms/ 




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



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.