- Joined
- 16 January 2018
- Posts
- 3
- Reactions
- 0
hi, i recently purchased amibroker. the coding that you need will take a long time to learn.
i have tried to use some from the afl library and they dont seem to be much good
written a couple of basic ones where im using ma crossovers and in back testing im getting some decent results. using only ma's is not really using amibroker to it full potential.
im looking at having a system where i trade medium term and hold a max of 10 positions
i would love some advice from people or some codes to play around with
thanks
The exit will determine the return distribution only - it's not producing excess profits. With your exit logic you set the desired win rate, win/loss amounts and the skew of the distribution. This is not obvious to most people.
Amibroker is unbeatable for figuring this out and requires only relatively simple coding, a few lines, typically. It should take weeks or months, not years to learn those basics.
Note: signals almost always have a short life-span
@Habakkuk, I don't understand what you mean by 'short life span'. Do you mean the optimal exit (in terms of profitability) is usually <3-5 days?
Also could you please this sentence in more detail? I don't follow.
"The exit will determine the return distribution only - it's not producing excess profits".
Thanks for all the detail here.'short life span' means that the signal strength 'wears off', e.g. an entry signal is good as soon as it is triggered, because by tomorrow or the next day it will typically have lost most of its validity - if it had any in the first place. The trade will (should) have moved in the right direction by then and some of the profit potential is gone. I hope that makes sense.
This might be controversial, especially for Fundamental Analysts who forecast stock performance several years ahead. But for the OP who wants to design a mechanical trading system it's sensible. One of my better systems has almost no pop on day one which is interesting.
It doesn't mean that there is an 'optimal' trade duration. That depends on several variables, just off the top of my head:
- system type, trend following obviously as long as it's your friend, momentum a bit shorter, mean reversion only a few days
- are there entry signals available for the trading capital?, if not you might consider letting it run for another day
- brokerage and spread; if you exit on the same day or the next, it can be expensive
I spent some time last year importing the 260 trades from peter2's thread into Amibroker, looking for a single mechanical logic exit that would perform as well as his discretionary ones, all 7 of them ... He was considering switching between 2* and 3*ATR trailing stops at that time.
From memory his average edge from entry until the next day's close was 1.5%. That's something I can only dream about. It then drops off very rapidly and is (on average) down to just a few basis points per day after 2 weeks or so. Some trades trended much longer than that, of course.
The trade exit determines the shape of the return distribution. Take the standard trend-following exit of "cut your losses short and let your profits run". You get a typical Win percentage of maybe 40% with av. profit/loss ratio 2:1 or better. The distribution has a long right tail, some very big winners, hopefully.
Let's do the exact opposite, "grab any profit when it's there and let your losses run". You won't find that in any trading book. The way it works is to look at the end of each day: if it was an 'UP' day, close the trade, regardless of whether it is in profit. If it was a 'DOWN' day, keep it open.
You will probably think that's sheer lunacy, but what you get is a win rate of typically > 60% and almost 1:1 profit/loss. The annoying thing is the long left tail, the occasional big loss.
In Amibroker it looks like this:
Sell = Close > Ref(Close, -1);
SellPrice = Close;
There are many other possibilities like > Open or > MA(something)
The important thing is to realise that the obvious, sensible, approved trend following exit has no edge - it is neutral. Therefore, logically, doing the opposite is also neutral. Most people would say "you're going to lose ALL YOUR MONEY".
I believe that mechanical exits don't/can't have an edge because they are forced to make a prediction every day. There is no such requirement for the entry logic. Entry can wait until the right condition arrives.
See if you can prove me wrong using random entry and a logic exit.
'short life span' means that the signal strength 'wears off', e.g. an entry signal is good as soon as it is triggered, because by tomorrow or the next day it will typically have lost most of its validity - if it had any in the first place. The trade will (should) have moved in the right direction by then and some of the profit potential is gone. I hope that makes sense.
This might be controversial, especially for Fundamental Analysts who forecast stock performance several years ahead. But for the OP who wants to design a mechanical trading system it's sensible.
It doesn't mean that there is an 'optimal' trade duration. That depends on several variables, just off the top of my head:
- system type, trend following obviously as long as it's your friend, momentum a bit shorter, mean reversion only a few days
- are there entry signals available for the trading capital?, if not you might consider letting it run for another day
- brokerage and spread; if you exit on the same day or the next, it can be expensive
I spent some time last year importing the 260 trades from peter2's thread into Amibroker, looking for a single mechanical logic exit that would perform as well as his discretionary ones, all 7 of them ... He was considering switching between 2* and 3*ATR trailing stops at that time.
From memory his average edge from entry until the next day's close was 1.5%. That's something I can only dream about. It then drops off very rapidly and is (on average) down to just a few basis points per day after 2 weeks or so. Some trades trended much longer than that, of course.
The trade exit determines the shape of the return distribution. Take the standard trend-following exit of "cut your losses short and let your profits run". You get a typical Win percentage of maybe 40% with av. profit/loss ratio 2:1 or better. The distribution has a long right tail, some very big winners, hopefully.
Let's do the exact opposite, "grab any profit when it's there and let your losses run". You won't find that in any trading book. The way it works is to look at the end of each day: if it was an 'UP' day, close the trade, regardless of whether it is in profit. If it was a 'DOWN' day, keep it open.
You will probably think that's sheer lunacy, but what you get is a win rate of typically > 60% and almost 1:1 profit/loss. The annoying thing is the long left tail, the occasional big loss.
In Amibroker it looks like this:
Sell = Close > Ref(Close, -1);
SellPrice = Close;
There are many other possibilities like > Open or > MA(something)
The important thing is to realise that the obvious, sensible, approved trend following exit has no edge - it is neutral. Therefore, logically, doing the opposite is also neutral. Most people would say "you're going to lose ALL YOUR MONEY".
I believe that mechanical exits don't/can't have an edge because they are forced to make a prediction every day. There is no such requirement for the entry logic. Entry can wait until the right condition arrives.
See if you can prove me wrong using random entry and a logic exit.
Not sure if this proves anyone wrong, but food for thought regarding random entries.
Skip the backtest dreaming and try this. Create your signal and then plot a shape on the chart whenever the signal criteria is met. This way you get a visualisation of what price action ensued the signal/s. Flip through chart histories and pretty soon you will know what usually happens after the signal. Saves a lot of time.i would love some advice from people or some codes to play around with
thanks
Thanks Trav but i wanted to do it automatically in Coding to understand its effect in back testI found this via the Amibroker Forum
http://www.amibroker.com/kb/2015/02/14/choosing-first-day-of-the-week-for-weekly-compression/
Hopefully it helps
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?