If I can butt-in.:)  The first piece of elegant-looking code is a loop, the 
second frumpy-looking code uses array processing.

The difference in practical terms is speed.  The loop code processes through 
each price-bar individually but "frumpy" does all the calculations as an array, 
which is far faster.  Tomasz recommends avoiding loops if you can with AB 
unless you're an advanced user.  (And you can do some pretty amazing things 
without looping, too, so take heart.)


Sebastian

--- In [email protected], "matrix10014" <alla...@...> wrote:
>
> Thank you Mike..
> 
> I do have a couple of questions.Amibroker gives an example of scaling out of 
> trades and uses code such as the following snippet.
> 
> -------------------------------------------
> priceatbuy=0; 
> highsincebuy = 0; 
> 
> exit = 0; 
> 
> for( i = 0; i < BarCount; i++ ) 
> { 
>    if( priceatbuy == 0 AND Buy[ i ] ) 
>     { 
>        priceatbuy = BuyPrice[ i ]; 
>     } 
> 
>    if( priceatbuy > 0 ) 
>     { 
> -------------------------------------------
> 
> I have a better chance of running a 3 minute mile than coding something like 
> that.I noticed in the examples you sent me,the code was more digestable..Here 
> is a snippet of what you sent
> 
> ------------------------------------------------------------------
> "Buy = firstTrigger + (secondTrigger * sigScaleIn) + (thirdTrigger * 
> sigScaleIn)
> + (fourthTrigger * sigScaleIn);
> //SetPositionSize(IIf(firstTrigger, 100, IIf(secondTrigger, 200,
> IIf(thirdTrigger, 300, 400))), spsShares);
> SetPositionSize(IIf(firstTrigger, 1000, IIf(secondTrigger, 2000,
> IIf(thirdTrigger, 3000, 4000))), spsValue);"
> -----------------------------------------------------------------
> 
> What are the differences between the two approaches?
> 
> If I understand FLIP,EXREM,VALUEWHEN,SIGSCALEIN and other functions in your 
> code,does that serve as a workoaround for the code at the top of the 
> page??Are those functions intended for mere mortals such as myself??
> 
> Thanks for the help,
> 
> 
> Allan
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --- In [email protected], "Mike" <sfclimbers@> wrote:
> >
> > Hi,
> > 
> > There have been a couple of complete examples in the last week or so:
> > 
> > http://finance.groups.yahoo.com/group/amibroker/message/146956
> > http://finance.groups.yahoo.com/group/amibroker/message/146976
> > 
> > Mike
> > 
> > --- In [email protected], "matrix10014" <allansn@> wrote:
> > >
> > > Would anyone be so kind to post code to scale in to a position.I have a 
> > > bear of a time coding in AFL and would like to purchase 50% of my 
> > > position on a signal,and the other 50% xATR's lower i.e 
> > > entry price - optimized value x ATR..
> > > 
> > > 
> > > Thanks in advance
> > > 
> > > Allan
> > >
> >
>


Reply via email to