Amibroker: Change Sell condition based on # of consecutive losses - Aussie Stock Forums

# Thread: Amibroker: Change Sell condition based on # of consecutive losses

1. ## Amibroker: Change Sell condition based on # of consecutive losses

Hi,

I'm not too bad with AFL coding but not sure where to start with a situation I want to try and code.
Imagine I have a sell condition such as:
period = 30;
Sell = cross(c,MA(c,period));

What I want to do is backtest some logic were if I'm trading and I have more than x number of consecutive loses I can change the period variable from 30 to say 10.

The idea is that if I'm on a bit of a losing streak due to poor trading conditions for my system I can tighten the sell citeria to limit drawdown. If I then win a trade the period variable resets to 30.

Would anyone have any idea how I can do this from a backtesting perspective. I'm thinking the custom backtester but not sure how I'd work out consecutive loses and then use this to change hthe sell criteria on the fly for the next trade?

Any ideas?

Thanks

2. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

I was looking into this and I think as a first step it might be easier to look at the consec losses and then just reduce the position size until I get y number of consec winners.
I can see via the custombacktester objects that I can work out the profit (and therefore whether it was a W or L) via the trade object. However, it looks like I then have to somehow go back to the signal object in order to then change the position size for subsequent trades, not really sure if this is the correct approach.
Any one with custom backtester knowledge out there to give me a few hints on this?

Thanks

3. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

Originally Posted by chesl73
I was looking into this and I think as a first step it might be easier to look at the consec losses and then just reduce the position size until I get y number of consec winners.
I can see via the custombacktester objects that I can work out the profit (and therefore whether it was a W or L) via the trade object. However, it looks like I then have to somehow go back to the signal object in order to then change the position size for subsequent trades, not really sure if this is the correct approach.
Any one with custom backtester knowledge out there to give me a few hints on this?

Thanks
Have you tried Marcin or TJ?

I asked them a very similar question a while back, but unfortunately the answer was above my level of understanding! Have you read this?
http://www.amibroker.org/userkb/2008...r-interface-2/

Marcin did offer this: "For individual symbols – you may also be tracking trades in a for loop or compare ValueWhen(Sell,C) - ValueWhen(Buy,C) and determine position-sizing based on that". Makes perfect sense but I don't know how to code that.

If you work it out, please let us know.

4. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

when you say 'have i tried mancin or TJ'?
What do you mean? How do I contact them?

I've read the user guide on it and I get it as I have a background in OO programming but it's more understanding how I'd do it rather than the actual coding of it.

Thanks

5. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

Originally Posted by chesl73
when you say 'have i tried mancin or TJ'?
What do you mean? How do I contact them?

I've read the user guide on it and I get it as I have a background in OO programming but it's more understanding how I'd do it rather than the actual coding of it.

Thanks
Have you paid for your copy of Amibroker?

6. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

I guess if you don't know who Marcin and TJ are, maybe you've got an illegal copy. If it's stolen, you're not going to get help from anyone

7. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

Originally Posted by chesl73
when you say 'have i tried mancin or TJ'?
What do you mean? How do I contact them?
http://www.amibroker.com/support.html

8. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

Yes, I have a paid copy. I know that TJ is the guy who developed Amibroker but I don't know who Mancin is - that doesn't automatically mean I have stolen a copy.
I know I can get support but I see support as something they would provide if there was a bug in the software, I didn't know it extended to helping the buyer understand the custom backtester with specific questions and answers? Maybe it does?
Anyway, if your sole response to my question is to accuse me of theft then maybe you shouldn't bother replying.

9. ## Re: Amibroker: Change Sell condition based on # of consecutive losses

Do a search on "amibroker Custom BackTester Interface Rev 5 July 2007"

What you need to do is access the trades property as shown in code below from that document.
}

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Aussie Stock Forums