Hi all...

Hopefully my last question regarding looping.The last piece of code 
i am trying to implement is having a floor for the trailing stop to 
be activated...The first part of the code is the profit target where 
I sell 50% of the position up 20 percent.I would like to have a 
trailing stop,only if this is true.I would have thought that by 
coding "if = =1" into the loop,that would have done the trick.It 
didnt.Below is the parts of the code that are relevant..Any help 
appreciated,and thank you Terry for helping out
---------------------------------------------------------------------
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 ] >= ( 1 + FirstProfitTarget * 0.01 ) * 
priceatbuy ) 
       { 
         // first profit target hit - scale-out 
         exit = 1; 
         Buy[ i ] = sigScaleOut; 
       } 
--------------------------------------------------------------------
    if(Low[ i ] <= ( 1 - TrailingStop * 0.01 ) * highsincebuy )



 
//Shouldnt this work???
 if(exit==1 AND Low[ i ] <= ( 1 - TrailingStop * 0.01 ) * 
highsincebuy ) 
      









Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

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



Reply via email to