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

[amibroker] Why doesn't this work



PureBytes Links

Trading Reference Links

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 ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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 http://docs.yahoo.com/info/terms/