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

[amibroker] Re: Stoploss that moves to break-even point and stays there


  • Date: Fri, 19 Feb 2010 11:39:24 -0000
  • From: "smrcek18" <smrcek18@xxxxxxxxx>
  • Subject: [amibroker] Re: Stoploss that moves to break-even point and stays there

PureBytes Links

Trading Reference Links

Thank you Mike! It works :)

Smrcek

--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Hi,
> 1. You should not be passing expressions like "exitAtStop = True" for
> parameters. Just pass True. The "=" part is for documentation only.
> 2. You don't need a loop here. ApplyStop accepts dynamic stop values via
> an array. Try the following (assuming that Buy does not have any
> redundant signals - i.e. use ExRem):
> PriceBought = ValueWhen(Buy, Close);
> Threshold = Close >= 1.05 * PriceBought;
> Threshold = Flip(Threshold, Sell);
> 
> Stop =  IIF(Threshold, 0, 1);
> ApplyStop(stopTypeLoss, stopModePercent, Stop, 1, true);
> 
> Mike
> --- In amibroker@xxxxxxxxxxxxxxx, "smrcek18" <smrcek18@> wrote:
> >
> >
> >
> >
> >
> >
> > Anyone knows what is wrong with the code below?  It gives me strange
> results. It ignores BreakevenTarget variable...
> >
> > BreakevenTarget = 5;
> > priceatbuy=0;
> > highsincebuy = 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( highsincebuy >= ( 1 + BreakevenTarget * 0.01 ) * priceatbuy
> )
> >        {
> >        // 5% target hit
> >   sellpercent = 0;
> >        } else {
> >   sellpercent = 1;
> >  }
> >      }
> > }
> >
> > ApplyStop(stopTypeLoss, stopModePercent,
> sellpercent,exitatstop=True,volatile=True,ReEntryDelay=False);
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "smrcek18" smrcek18@ wrote:
> > >
> > > Hello,
> > >
> > > Can anyone help me with coding a stoploss that goes to break-even
> point and stays there?
> > >
> > > Let's look at this simple code:
> > >
> > > BuyPrice = C;
> > > SellPrice = C;
> > >
> > > Buy=C>Ref(H,-1);
> > > Sell=C<Ref(L,-1);
> > >
> > > ApplyStop(stopTypeLoss, stopModePercent, 1, True);
> > >
> > > I would like that when the price reaches +5% the stoploss moves from
> 1% to break-even point (zero+commision+spread) and stays there. Second
> option is to have a stoploss that goes to break-even point after a
> couple of days (lets say 10 days) and stays there.
> > >
> > > I was looking at similar example here
> http://www.mail-archive.com/amibroker@xxxxxxxxxxxxxxx/msg45865.html, but
> it's too complicated for me :(
> > >
> > > I would appreciate if anyone could help me with that. Thanx.
> > >
> >
>




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

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/