Hi all
Last year I was playing around with a system where for a buy-entry I used the condition that a candle must have closed below (outside) of a 2 deviation bollinger band (BB) and and RSI below a certain level (say 25). Then, I traded opposite to this and closed the trade at some DeMarker "oversold level".
Anyway, when I backtested this (99.% tick data quality from 2003 on) this sorta worked, but frankly not to well. The reason is, that I got whacked when the markets where trending, i.e. I got a few candles in a row outside of BB and also a respective oversold RSI entry. And then I tried to overcome this (stubbornly) by a mini-martingale, which meant adding up successively to consecutive trades in the same direction.
Guess what - worked, but not really. I made the Prfit factor go from 1.18 to 1.22. And the stagnation.... let's not even talk about that.
This got me thinking about two major points:
1. How to identify range markets vs trending markets?
2. Once you have figured out 1., then make the performance better by avoiding a few losers. i.e. have an approach for trending conditions and an approach for ranging conditions.
A trader's wet dream, isn't it? LOOOL
Regarding point 1, I think I have a solution, and that is the "slope" of a Simple Moving Average (SMA) drawn on closing prices. I want to be long "somehow" when price is above the SMA and it is sloping up. Well, since it's a bit tough to calculate an "angle" of a SMA, I think the way around would be to calculate the price increase over a given number of bars (or data points if you wish).
So, the initial set of parameters would be
1. What period of the SMA do I want to use (say 50)
2. What is the average price increase/decrease in % over the last, say 5 bars? (Rate of change= ROC)
Let's assume the price increase over the last 5 bars of SMA(50) has been 20% (just a figure, I have no clue).
Then, we need to say "OK, if the price is above the SMA (50) and the price increase over the last 5 bars is above 15%, I will consider it up-trending market, and I want a way to jump in"
Here comes my question: What's a good way to get in?
Now that the market is established, I need:
a) A buy entry signal
b) A stop loss
c) An exit in the form of a take profit or a trailing stop or exiting at an indicator value.
Regarding a)
My idea was to use an "oversold"signal of a rather fast RSI, say RSI(5).
Entry condition FOR A TRENDING MARKET would be:
If price above SMA(50) and ROC(50) over 5 bars is greater than 15% and RSI (5) is below 30, then buy.
Vice versa for a sell:
If price below SMA(50) and ROC(50) over 5 bars is greater than -15% and RSI (5) is above 70, then sell.
Regarding b)
Stop loss could be a multiple of Average True Range e.g 4 x ATR(14), or some fixed pip stop loss. (I'm not a freind of those, as they do not adapt to the market volatility. Other options would be to place the stop loss at a technical level, but I have no clue how that could be coded.
Regarding c)
It should have an exit like "trailing stop at e.g. 10% of profit. So, if the trade is up 60 pips, then the stop loss is at entry + 6 pips. (not sure these are enough conditions. Don't we need to define anything else? hmm...
For the indicator value, it could get out at RSI (5) closing above 70. (But I read somewhere that the same indicator that gets you in hsouldn't get you out, but who knows...)
Now, let's talk about a RANGING MARKET:
Since we defined a trending market by ROC (50) over 5 bars as anything greater than 15% or smaller than -15% (again, these number I just pulled out of the air), then a ranging market is where the ROC is smaller than 15% and greater than -15%.
In this case, we do actually want to trade the RSI as if it was reverting to the mean, i.e. for a sell signal if price is ABOVE the SMA(50) we will go short on RSI (5) greater than 70:
So, that's about my thinking of how a trading system could look like.
Here on more point to this:
I think it's not a good idea to indiscriminately use always 1% or 2% on every single trade signal. Some are better than others. even if the conditions are the same. This might sound confusing but, let's say that the EA always buys when RSI(5) closes below 30. Then it would by with 2% if RSI closes at 25 or if it closes at 29 or a 12. But, it might make sense to examine, if the trades that come from extremer levels (e.g RSI(5) closes at 8) do not result in a sharper reversal or trend continuation and also have a higher likelihood of not being stopped out and hence do not deserve a higher allocation of risk capital, say 5% of balance.
Aaaanyway....
I'd appreciate your ideas, and of course if someone feels like coding this, I'm happy to do the testing, I have TickData Suite and can do quality backtests.
Thanks to all in advance
Last year I was playing around with a system where for a buy-entry I used the condition that a candle must have closed below (outside) of a 2 deviation bollinger band (BB) and and RSI below a certain level (say 25). Then, I traded opposite to this and closed the trade at some DeMarker "oversold level".
Anyway, when I backtested this (99.% tick data quality from 2003 on) this sorta worked, but frankly not to well. The reason is, that I got whacked when the markets where trending, i.e. I got a few candles in a row outside of BB and also a respective oversold RSI entry. And then I tried to overcome this (stubbornly) by a mini-martingale, which meant adding up successively to consecutive trades in the same direction.
Guess what - worked, but not really. I made the Prfit factor go from 1.18 to 1.22. And the stagnation.... let's not even talk about that.
This got me thinking about two major points:
1. How to identify range markets vs trending markets?
2. Once you have figured out 1., then make the performance better by avoiding a few losers. i.e. have an approach for trending conditions and an approach for ranging conditions.
A trader's wet dream, isn't it? LOOOL
Regarding point 1, I think I have a solution, and that is the "slope" of a Simple Moving Average (SMA) drawn on closing prices. I want to be long "somehow" when price is above the SMA and it is sloping up. Well, since it's a bit tough to calculate an "angle" of a SMA, I think the way around would be to calculate the price increase over a given number of bars (or data points if you wish).
So, the initial set of parameters would be
1. What period of the SMA do I want to use (say 50)
2. What is the average price increase/decrease in % over the last, say 5 bars? (Rate of change= ROC)
Let's assume the price increase over the last 5 bars of SMA(50) has been 20% (just a figure, I have no clue).
Then, we need to say "OK, if the price is above the SMA (50) and the price increase over the last 5 bars is above 15%, I will consider it up-trending market, and I want a way to jump in"
Here comes my question: What's a good way to get in?
Now that the market is established, I need:
a) A buy entry signal
b) A stop loss
c) An exit in the form of a take profit or a trailing stop or exiting at an indicator value.
Regarding a)
My idea was to use an "oversold"signal of a rather fast RSI, say RSI(5).
Entry condition FOR A TRENDING MARKET would be:
If price above SMA(50) and ROC(50) over 5 bars is greater than 15% and RSI (5) is below 30, then buy.
Vice versa for a sell:
If price below SMA(50) and ROC(50) over 5 bars is greater than -15% and RSI (5) is above 70, then sell.
Regarding b)
Stop loss could be a multiple of Average True Range e.g 4 x ATR(14), or some fixed pip stop loss. (I'm not a freind of those, as they do not adapt to the market volatility. Other options would be to place the stop loss at a technical level, but I have no clue how that could be coded.
Regarding c)
It should have an exit like "trailing stop at e.g. 10% of profit. So, if the trade is up 60 pips, then the stop loss is at entry + 6 pips. (not sure these are enough conditions. Don't we need to define anything else? hmm...
For the indicator value, it could get out at RSI (5) closing above 70. (But I read somewhere that the same indicator that gets you in hsouldn't get you out, but who knows...)
Now, let's talk about a RANGING MARKET:
Since we defined a trending market by ROC (50) over 5 bars as anything greater than 15% or smaller than -15% (again, these number I just pulled out of the air), then a ranging market is where the ROC is smaller than 15% and greater than -15%.
In this case, we do actually want to trade the RSI as if it was reverting to the mean, i.e. for a sell signal if price is ABOVE the SMA(50) we will go short on RSI (5) greater than 70:
So, that's about my thinking of how a trading system could look like.
Here on more point to this:
I think it's not a good idea to indiscriminately use always 1% or 2% on every single trade signal. Some are better than others. even if the conditions are the same. This might sound confusing but, let's say that the EA always buys when RSI(5) closes below 30. Then it would by with 2% if RSI closes at 25 or if it closes at 29 or a 12. But, it might make sense to examine, if the trades that come from extremer levels (e.g RSI(5) closes at 8) do not result in a sharper reversal or trend continuation and also have a higher likelihood of not being stopped out and hence do not deserve a higher allocation of risk capital, say 5% of balance.
Aaaanyway....
I'd appreciate your ideas, and of course if someone feels like coding this, I'm happy to do the testing, I have TickData Suite and can do quality backtests.
Thanks to all in advance
Demo only