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

RE: [amibroker] More Array Processing for Newbies



PureBytes Links

Trading Reference Links

Not the best place to use loops, Kevin.
Do you really want to mix arrays and array elements?

1-Using Pos[i], requires working with H[i] and L[i] and calcing HHV and LLV
in inner loops.

2-Your type mismatch can be fixed by using Pos.
---------
Filter=1; i=1; Pos=1;
Period = EndValue(BarIndex())-BeginValue(BarIndex())+1; //useless
while( i < Period)
{
Pos=IIf(H>Ref(HHV(H,15),-1),1,
IIf(L<Ref(LLV(L,15),-1),-1,Pos[i-1]));
i=i+1;
}
AddColumn(Pos, "POS", 1.4 );
--------

3-Why not throw out the useless while loop?
---
Filter=1;
Pos=IIf(H>Ref(HHV(H,15),-1),1,
IIf(L<Ref(LLV(L,15),-1),-1,Pos[i-1]));
AddColumn(Pos, "POS", 1.4 );
---

Bob

-----Original Message-----
From: Kevin243@xxxxxxx [mailto:Kevin243@xxxxxxx]
Sent: Wednesday, May 21, 2003 5:17 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] More Array Processing for Newbies


I'm planning to write my own backtesting routine via the Explore, so that I
can generate the trade statistics that I want. (ie. normalized returns,
Optimal F, etc.)

But I have to understand the fine art of writing loops.  This is a loop to
establish a position, that isn't working.  Can anybody please help?

Filter=1;

Period = EndValue( BarIndex() ) - BeginValue( BarIndex() )+1;

i=1;

Pos[0]=1;
while( i < Period) {Pos[i]=IIf(H>Ref(HHV(H,15),-1),1,
IIf(L<Ref(LLV(L,15),-1),-1,Pos[i-1])); i=i+1;}


AddColumn(Pos, "POS", 1.4 );


Thanks
Kevin Campbell
Yahoo! Groups Sponsor
ADVERTISEMENT




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.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/uetFAA/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 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/