Thanks for that Graham. The bigger problem is I get an error message 
saying that I can't use conditions in this format. What does that 
mean?

--- In [email protected], Graham <[EMAIL PROTECTED]> wrote:
>
> Just this part I think
> High[ i ] >= ProfitTarget + priceatbuy)
> 
> -- 
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://www.aflwriting.com
> 
> 
> 
> On 16/04/07, bernardedmond01 <[EMAIL PROTECTED]> wrote:
> > Could someone take a look at this pls?
> > I'm trying to code exiting once price is above buyprice by 3*ATR
(20)
> > at the time of purchase. The basic code is based on the user 
guide
> > but I've gone wrong somewhere.
> > Thanks in advance.
> >
> > BuyATR=ValueWhen(Buy,ATR(20)); // profit
> >
> > ProfitTarget = 3*BuyATR;
> > priceatbuy=0;
> > highsincebuy = 0;
> >
> > exit = 0;
> >
> > for( i = 0; i < BarCount; i++ )
> >
> > {
> >    if( priceatbuy == 0 AND Buy[ i ] )
> >      {
> >        priceatbuy = BuyPrice[ i ];
> >      }
> >
> >    if( priceatbuy > 0 )
> >      {
> >        highsincebuy = Max( High[ i ], highsincebuy );
> >
> >       if( exit == 0 AND
> >           High[ i ] >= ProfitTarget * priceatbuy)
> >        {
> >          // first profit target hit - scale-out
> >          exit = 1;
> >          Buy[ i ] = sigScaleOut;
> >        }
> >
> >   }
> > }
> >
> > SetPositionSize( 50, spsPercentOfPosition * ( Buy ==
> > sigScaleOut ) ); // scale out 50% of position
> >
> >
>


Reply via email to