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

Re: [amibroker] Re: Why doesn't this work



PureBytes Links

Trading Reference Links


James,
 
Even as an Armor Officer, I still call Artillery the "King of Battle". : )
 
Regarding your code, ApplyStop needs a constant in the "type" param.  A way of getting around that is via the LastValue function.  I've tried the code, and it checks out.  See below.
 
Regards,
Gary
 

Var1=IIf(Close>=(BuyPrice+0.003),2,1);
Var2=IIf(Close<(BuyPrice+0.003),0.005,0.002);
ApplyStop(LastValue(Var1),2,Var2,True,False);the_real_redleg <james.hall3@xxxxxxxxxxx> wrote:
OK, 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: 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.Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 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. 
Do you Yahoo!?
Free Pop-Up Blocker - Get it now






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.