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

Re: [amibroker] Re: Modified Trailing stop



PureBytes Links

Trading Reference Links

If you have any delays in the trade entries/exits you must make
allowance for this in the loop. Buy[i] refers to the buy signal bar,
not entry bar which is where the BuPrice is taken
If bar delays are 1 bar then

for( i = 1; i < BarCount; i++ )
{
    if( priceatbuy == 0 && Buy[ i-1 ] )
    priceatbuy = BuyPrice[ i ];



-- 
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com


On 14/03/2008, pmxgs <pmxgs@xxxxxxxxxx> wrote:
> Hi Howard,
>
>   yes, na example would be nice.
>   I've tried to modify this one (included in the users guide), but I'm
>  having trouble with referencing the entry price.
>
>  /* a sample low-level implementation of Profit-target stop in AFL: */
>
>  Buy = Cross( MACD(), Signal() );
>
>  priceatbuy=0;
>
>  for( i = 0; i < BarCount; i++ )
>  {
>      if( priceatbuy == 0 && Buy[ i ] )
>      priceatbuy = BuyPrice[ i ];
>
>      if( priceatbuy > 0 && SellPrice[ i ] > 1.1 * priceatbuy )
>      {
>        Sell[ i ] = 1;
>        SellPrice[ i ] = 1.1 * priceatbuy;
>        priceatbuy = 0;
>      }
>      else
>        Sell[ i ] = 0;
>  }
>
>   thanks
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Howard B" <howardbandy@xxx> wrote:
>  >
>
> > Hi pm --
>  >
>  > You will need to write afl code that includes a loop that looks at
>  the data
>  > each bar.  Do you know how to do that, or would like an example?
>  >
>  > Thanks,
>  > Howard
>  >
>
> > On Thu, Mar 13, 2008 at 6:09 AM, pmxgs <pmxgs@xxx> wrote:
>  >
>  > >   Hi all,
>  > >
>  > > I would like to implement a "modified trailing stop", that just
>  > > trails one time, for example I define the trailing stop to trail by
>  > > 1%. Then, as soon as the price goes up by 1% the stop is raised to the
>  > > entrypoint level (which is the usual way a trailing stop works), but
>  > > from this moment on, the stop would stay at that point even if the
>  > > price rose 10%.
>  > > Can someone give an hint on how I can accomplish this?
>  > >
>  > > thanks
>  > >
>  > >
>  > >
>  >
>
>
>
>  ------------------------------------
>
>  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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
>  http://www.amibroker.com/devlog/
>
>  For other support material please check also:
>  http://www.amibroker.com/support.html
>
> Yahoo! Groups Links
>
>
>
>
>
>

------------------------------------

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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