PureBytes Links
Trading Reference Links
|
Tomasz,
I'll go thru the tutorial again.
I'd like to implement your iterative solution (which works fine for
the explore I presented), but in a backtesting Short/Cover situation I
will need to do the iteration from the point at which each Short
signal is generated.
This means that I'll need to iterate from the bar(num) of the current
Short signal rather than from the beginning of the array (i = 1).
ie... for (i = ShortBar; i < BarCount; i++);
I know it is probably documented somewhere, but I cannot find how to
start a 'for loop' at the current bar where a signal is generated.
A HINT pleeeazeee... (I'm about worn out on this one) <g>
Thanks for your help.
Phsst
--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
wrote:
> Hello,
>
> Min function works OK. It is just your formula that assumes things that
> do not happen. Specificaly:
>
> x = Min( Ref(H,-1) , Ref(CoverPrice, -1) );
> CoverPrice = x;
>
> This statement is performed only ONCE
> So your CoverPrice = x
> does NOT affect evaluation of first line.
>
> Your code makes assumption that it would be iterated but it won't.
> x array will be filled ONCE with minimum value.
> Since CoverPrice array is initialized to 9999 it will just
> give you Ref( H, -1 ).
>
> Read the Tutorial: Understanding how AFL works.
> ===============================
> ===============================
> ===============================
> ===============================
>
> If you want iteration (as in TS) you need to WRITE it explicitely:
>
> CoverPrice[ 0 ] = High[ 0 ];
>
> for( i = 1; i < BarCount; i++ )
> {
> CoverPrice[ i ] = Min( High[ i - 1 ], CoverPrice[ i - 1 ] );
> }
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message -----
> From: "Phsst" <phsst@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Thursday, August 07, 2003 8:18 PM
> Subject: [amibroker] MIN function not working
>
>
> > In a SHORT backtest I want to make my own assignments to the
> > CoverPrice array... then use the CoverPrice as the 'trailing buy stop'
> > price that I use to stop out a position.
> >
> > I NEVER want the CoverPrice to INCREASE.
> >
> > I ALWAYS want the CoverPrice to either REMAIN UNCHANGED OR DECREASE
> > with each new bar.
> >
> > I've tried many gyrations of AFL code to accomplish this and have
> > spent more hours on it than I care to admit to, but I have narrowed my
> > problem down to the failure of the MIN function to return the lowest
> > value.
> >
> > Here is an extremely simple exploration to demonstrate the problem:
> > ------------------------------------------
> >
> > // Explore and Debug Trailing Stop logic
> >
> > for( i = 1; i < BarCount; i++ ) // Pad CoverPrice array with HIGH
VALUES
> > {
> > CoverPrice[i] = 99999;
> > }
> >
> > // I verified that entire CoverPrice array now padded with 99999's
> >
> > x = Min( Ref(H,-1) , Ref(CoverPrice, -1) );
> > CoverPrice = x;
> >
> > Filter = 1;
> >
> > AddColumn(x,"x = Min(Ref(H,-1),Ref(CoverPrice, -1))",6.3);
> > AddColumn(Ref(H, -1),"Ref(H, -1)",6.3);
> > AddColumn(Ref(CoverPrice, -1),"Ref(CoverPrice,-1)",6.3);
> > AddColumn(CoverPrice,"CoverPrice",6.3);
> > AddColumn(H,"H",6.3);
> >
> > ----------------------------------------
> >
> > Run the above exploration against any current issue (I'm testing with
> > SPY) in AB and you will see that in the statement:
> >
> > x = Min( Ref(H,-1) , Ref(CoverPrice, -1) );
> >
> > variable x is ALWAYS being assigned the value of Ref(H, -1) instead of
> > the lowest value of the two values.
> >
> > Am I missing something or is this an AB issue that I need to refer to
> > Tomasz?
> >
> > Regards,
> >
> > Phsst
> >
> >
> >
> >
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > 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/
> >
> >
> >
------------------------ 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/l.m7sD/LIdGAA/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
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|