hi,
maybe add
SetTradeDelays(0,0,0,0);
to your code. And set in the AA settings
window:
1) activate stops immediately
2) allow same bar exit
and add after the Applystop in your
code:
SellPrice = C; CoverPrice = C;
Equity(1);
this way it will exit at the close if it exits
after 5 bars. If it hits the profit level it should exaclty exit at that
price,
rgds, Ed
----- Original Message -----
Sent: Friday, April 08, 2005 8:30
PM
Subject: [amibroker] Re: ApplyStop
Question
Ed, unfortunately this code don't exit at specifc
price. He exit when the stop reach your level but he exit at open
price.
I need exit exactly at 1.25
Thank you
anyway
--- Giuseppe
--- In amibroker@xxxxxxxxxxxxxxx, "ed nl"
<ed2000nl@x...> wrote: >
hi, > > I have some code I used before pasted below. It uses
ATR(10) for a stopprofit (from the entryprice), or in terms of an absolute
price it takes a profit at: BuyPrice + ATR(10) or at
ShortPrice - ATR (10). If profit target is not hit it exits after 5 days.
You can put the code in a chart and do a backtest on the symbol for all
quotes. Then you will see arrows appearing in the chart. > >
Applystop can not use the absolute price. So the absolute exit price
BuyPrice + ATR(10) can not be used in Applystop. Instead it needs the
points with respect to the BuyPrice which is ATR(10). > > Don't
have code lying around which you could use with futures but the idea is
the same. Hope this helps, > > rgds, Ed > > >
> > SetBarsRequired(10000,10000); > SetChartOptions(0,
chartShowDates); > > Buy = Ref(StochK(10),-1) < 10; >
BuyPrice = O; > > Short = Ref(StochK(10),-1) > 90; >
ShortPrice = O; > > // absolute value > absV = ATR(10);
> > profitStop = ValueWhen(Buy OR Short,absV); > >
Sell = 0; > Cover = 0; >
ApplyStop(stopTypeProfit,stopModePoint,profitStop,ExitAtStop = 1,Volatile
= False, ReentryDelay = 1 ); > nnb = 5;; > ApplyStop(
stopTypeNBar,stopModeBars,nnb,ExitAtStop = 1,Volatile = False,
ReentryDelay = 1 ); > > Equity(1); > > // these
profitStop levels I add as illustration inside the chart >
profitLevelLong = ValueWhen(Buy,BuyPrice + absV) * Flip (Buy,Sell) ;
> profitLevelLong = IIf(profitLevelLong,profitLevelLong,Null); >
profitLevelShort = ValueWhen(Short,ShortPrice - absV) * Flip (Short,Cover);
> profitLevelShort = IIf(profitLevelShort,profitLevelShort,Null);
> > // chart > Plot(C,"C",1,64); >
Plot(profitLevelLong,"profitStop level for a Long
position",colorBrightGreen,1); > Plot(profitLevelShort,"profitStop
level for a Short position",colorRed,1); >
PlotShapes(IIf(Buy,shapeUpArrow,0),colorLightBlue, layer = 0, yposition =
BuyPrice, offset = 0 ); >
PlotShapes(IIf(Sell,shapeDownArrow,0),colorYellow, layer = 0, yposition =
SellPrice, offset = 0 ); >
PlotShapes(IIf(Short,shapeDownTriangle,0),colorLightBlue, layer = 0,
yposition = ShortPrice, offset = 0 ); > > >
> ----- Original Message ----- > From:
ami_trader > To: amibroker@xxxxxxxxxxxxxxx
> Sent: Friday, April 08, 2005 7:06 PM >
Subject: [amibroker] Re: ApplyStop Question > > >
> Thank you ed. > It doesn't work for me,
but maybe I don't understand. > > My pseudocode
is: > > Buy this bar at yesterday H - 10
tick > Stop Loss when the price is -14 tick from entry
price > Take Profit when the price is +6 tick from entry
price > > Can you give me an example? >
> --- > Giuseppe >
> --- In amibroker@xxxxxxxxxxxxxxx, "ed nl"
<ed2000nl@xxxx> wrote: > > hi, >
> > > yes it is possible. If you use
stopModePoint then the value you > enter is the the
number of points with respect to the entryprice. So >
you have to rewrite it in such a way that you can use an absolute
> price. > > > >
For instance you buy at 40 and you want to take a profit at 42.
> Then you can use for instance: > >
> > profitStop = ValueWhen(Buy, abs(40 -
42)); > >
ApplyStop(stopTypeProfit,stopModePoint,profitStop,ExitAtStop =
> 1,Volatile = False, ReentryDelay = 1
); > > > > I could give a more
complete example if needed, > > > >
rgds, Ed > > > >
> > > > ----- Original
Message ----- > > From: ami_trader
> > To: amibroker@xxxxxxxxxxxxxxx
> > Sent: Friday, April 08, 2005 5:52
PM > > Subject: [amibroker] Re: ApplyStop
Question > > > >
> > > > Please, help
me. > > > > How do I
exit or enter at specific price ? > > Is it
possible with AB? > > >
> --- > >
Giuseppe > > > >
> > --- In amibroker@xxxxxxxxxxxxxxx,
"ami_trader" <ami_trader@xxxx> > >
wrote: > > > >
> > Is it possible to exit exactly at stop loss
price? > > > >
> > ApplyStop( stopTypeLoss, stopModePoint, 0.0014, 0, 0,
0); > > > >
> > Exit exactly at stop loss value (Entry Price -
0.0014) > > > >
> > > > > Thanks in
advance > > > >
> > > > >
--- > > > Giuseppe >
> > > > > >
> > > > > 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 > > >
> a.. To visit your group on the web, go
to: > > http://groups.yahoo.com/group/amibroker/ >
> >
> b.. To unsubscribe from this group, send an email
to: > >
amibroker-unsubscribe@xxxxxxxxxxxxxxx >
> >
> c.. Your use of Yahoo! Groups is subject to the
Yahoo! Terms > of Service. > > >
> > > 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 > > a.. To visit your
group on the web, go to: > http://groups.yahoo.com/group/amibroker/ >
> b.. To unsubscribe from this group, send an
email to: >
amibroker-unsubscribe@xxxxxxxxxxxxxxx >
> c.. Your use of Yahoo! Groups is subject to
the Yahoo! Terms of Service.
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
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
|