http://www.amibroker.com/kb/index.php?s=applystop
Since no one chimed in yet, thought I'd share a link that may point you to a possible solution.
Without trying and not having the time to try I would think it'd be possible to use some iif() logic to determine stop point.
profitpoint = iif(barssince(buy)==barssince(r2),r2profitpoint,r1profitpoint);
Issues I can think of right away would be with something as simple as your example that r1 and r2 can both be true and throw it off, however using any method will cause issues as you can never know by looking at a single bar which was true first, r1 or r2. Perhaps use another iif(r1 and r2,r1,r2) ( if both true take r1)
Another issue would be overlapping trades. With the backtestregular I don't believe it will be able to overlap signals so you may need to use some Exrem() functions to remove signals if in one setup (r1 or r2). This would however only allow one setup per symbol which may not be what you want.
I'm not familiar with capabilities of the the other backtest modes and the custom backtester. Could possibly read up on it yourself.
Also didn't read your entire code line for line but could be easier just to apply the profit/stops into the sell/cover variables in each loop.
If this didn't help I hope someone else chimes in.
Posted by: brandon.richard03@yahoo.com
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (2) |
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/
EmoticonEmoticon