PureBytes Links
Trading Reference Links
|
You
might take a look at the syntax for your applystop.....
<SPAN
class=242101618-28112003>
SYNTAX
applystop( type, mode,
amount, exitatstop, volatile = False )
RETURNS
nothing
FUNCTION
controls built-in stops from the formula level (allows
optimization of stops)
Parameters:
type =0 = stopTypeLoss - maximum loss stop,1 =
stopTypeProfit - profit target stop,2 = stopTypeTrailing - trailing
stop,3 = stopTypeNBar - N-bar stop
mode = 0 - disable stop (stopModeDisable),1 - amount in
percent (stopModePercent), or number of bars for N-bar stop
(stopModeBars),2 - amount in points (stopModePoint);3 - amount in
percent of profit (risk)
amount = percent/point loss/profit trigger/risk
amount.This could be a number (static stop level) or an array (dynamic
stop level)
exitatstop = False - exits at defined price field,True -
exits at stop level
volatile - decides if amount (or distance) (3rd parameter)
is sampled at the trade entry and remains fixed during the trade (Volatile
= FALSE - old behaviour) or if can vary during the trade (Volatile = TRUE)
(allows single line Chandelier exit implementation)
EXAMPLE
/* max loss stop optimization */ApplyStop(
stopTypeLoss, stopAmountPercent, optimize( "max. loss stop level", 10, 2,
30, 1 ), True );
/* single-line implementation of Chandelier exit
*/ApplyStop(stopTypeTrailing, stopModePoint, 3*ATR(14), True, True );
Regards,
Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: the_real_redleg
[mailto:james.hall3@xxxxxxxxxxx]Sent: Friday, November 28, 2003 11:01
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: [amibroker] Re:
Why doesn't this workOK, fix made but now I get the
following error:Line 8, Column
34:PositionSize=100000;Var1=IIf(Close>=(BuyPrice+0.003),2,1);Var2=IIf(Close<(BuyPrice+0.003),0.005,0.002);ApplyStop(Var1,2,Var2,True,False);---------------------------------^Error
2.Bad argumentsI didn't think my arguments were that bad.
(?)James--- In amibroker@xxxxxxxxxxxxxxx,
"the_real_redleg" <james.hall3@xxxx> wrote:> LOL!! That's what
I get for staring at the computer screen too long.> >
Thanks!> > > --- In amibroker@xxxxxxxxxxxxxxx, "Silvarius"
<silvarius@xxxx> wrote:> > the correct spelling of the
function is "IIF()" and not "IFF()". > It's that> > simple
;-)> > > > Best regards> > Jérôme ULRICH>
> -----Message d'origine-----> > De :
the_real_redleg [mailto:james.hall3@xxxx]> > Envoyé :
vendredi 28 novembre 2003 16:12> > À :
amibroker@xxxxxxxxxxxxxxx> > Objet : [amibroker] Why
doesn't this work> > > > > > Greetings
all,> > > > I'm trying to backtest a trailing
stop that is only implemented> > after a certain profit
target has been reach. I HAVE been trying > to>
> figure out if/else looping which should be the answer
according > to> > previous discussions here
(really!). But reading through the AFL> > reference
manual again this morning it seems to me that I should > be>
> able to do it by using the IFF function to assign differing
> results> > to variables that I then use within
the applystop function. Here > is> > the code
that is not working. (What I am want to do (for this> >
example) is have a 50 pip stoploss, but once I have 30 pips of>
> profit switch to a 20 pip trailing stop.)> > >
> Buy = Cross(EMA(Close,12),EMA(Close,26));>
> Short = Cross(EMA(Close,26),EMA(Close,12));>
> Sell = Short;> > Cover = Buy;>
> PositionSize=100000;> >
Var1=iff(Close>=(BuyPrice+0.003),2,1);> >
Var2=iff(Close<(BuyPrice+0.003),0.005,0.002);> >
ApplyStop(Var1,2,Var2,True,False);> > > > I get
a syntax error right at the first IFF.> > > >
Why does this give me a syntax error?> > > > Is
it possible to do what I'm attempting using this general>
> approach? (I'll keep banging my head against the intricacies
of> > if/else looping if I have to, but this would sure be
a lot > simpler.> > Even easier would be an if/else
function that works on arrays!)> > > > Thanks in
advance for your help.> > > > James> >
> > > >
Yahoo! Groups Sponsor>
>
ADVERTISEMENT> > > > > > > > >
> Send BUG REPORTS to bugs@xxxx> > Send
SUGGESTIONS to suggest@xxxx> >
-----------------------------------------> > Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx>
> (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)>
> -------------------------------------------->
> Check group FAQ at:> > <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html>
> > > Your use of Yahoo! Groups is subject to the
Yahoo! Terms of > Service.Send
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Yahoo! Groups Sponsor
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|