let_me_backtest_that (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 09, 2014, 03:55:37 PM |
|
Moving average crossovers are one of the most well known strategies. Unfortunately, they have the reputation of being great in theory, but bad in practice. There are two problems with most moving average crossover signals. First, they present a signal too late. Traders refer to this as "lag." Second, they give too many false signals that lead to quickly entering and exiting a market (or whipsaws). Traders refer to this as "noise". If we backtest three different moving average crossover strategies we can see the ways that lag/noise affects trading and how to decrease it. We will do this by backtesting three different moving average crossover systems and posting the results. (All backtests run from 1/1/2012-1/1/2014 and assume 1BTC is traded w/ no commissions) Simple Moving Average (SMA) Crossover If you were to backtest the most profitable daily simple moving average crossover (16/22). You would get a net profit of $881 with a 71% winning percentage, but a 17% drawdown. The strategy was profitable, but had quite a few whipsaws. See below; https://i.imgur.com/9nxRW7G.pngExponential Moving Average (EMA) Crossovers If you were to backtest the most profitable exponential daily moving average crossover (24/41). You would get a net profit of $755 with a 75% winning percentage and only a 5% drawdown. In other words, the longer EMA actually reduced the whipsaws and drawdown, but decreased net profit by increasing lag. See below https://i.imgur.com/9E5yTJV.pngDouble Exponential Moving Average (DEMA) Cross0ver Let's see what happens when we introduce a more adaptive moving average crossover, the DEMA. The backtested results for the most profitable combination of the DEMA crossover (18/33). You would get 8 trades with a net profit of $937 with 87.50% of winning trades and only an 8% drawdown. see below https://i.imgur.com/sWLfPqy.pngHere is what we learn from this research. Double Exponential Moving Averages introduce less noise and lag because they are more adaptive. More adaptive moving averages increase net profit and decrease drawdowns. There have been several attempts to make moving averages more adaptive I can post on them later as well. Each of the backtests were done through NinjaTrader. You can download NinjaTrader for free. Also, we have configured BTC historical data that is constantly updated for NinjaTrader. The link is below http://www.signalstrengthfinance.com/bitconnector-bitcoin-trading-on-ninjatrader/
|
|
|
|
the_sunship
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 09, 2014, 04:58:22 PM |
|
Many thanks for this, very appreciated!
😀
|
|
|
|
oda.krell
Legendary
Offline
Activity: 1470
Merit: 1007
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 09, 2014, 07:10:50 PM Last edit: June 09, 2014, 07:48:57 PM by oda.krell |
|
Much appreciated, OP. Never tried NinjaTrader, but will give it a shot. Also, what are the advantages of signing up for BitConnector for someone who doesn't use fully automated trading? Care for a sales pitch, I'm actually interested ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) Two short remarks about the DEMA results: One, the resulting trades in the 2013/2014 bear market are extremely "unintuitive". Example: You would have had to sit out (all fiat potentially) the entire dead cat bounce to ~1000. It's certainly possibly if you really, really trust your momentum signal, but, boy, I would have been nervous during that period. Two, I don't agree that the DEMA beats the other options straight and obvious. The optimal parameters you gave for the DEMA are, imo, almost certainly overfitted. The initial post-ATH SELL signal lands *perfectly* on the first rebound. I can't say exactly how much your profit comes from that instance, but it's probably a good chunk. This is almost certainly a lucky hit, and won't be reproducible. What I'm trying to say is: DEMA might still be the preferably choice for average crossover strategies, but at least the DEMA parameters you mention look like they owe a good deal of their profit to one lucky trade after the bubble popped. DEMA chart: ![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FHujbPTG.png&t=665&c=aHV-mt_d6l1q2w)
|
Not sure which Bitcoin wallet you should use? Get Electrum!Electrum is an open-source lightweight client: fast, user friendly, and 100% secure. Download the source or executables for Windows/OSX/Linux/Android from, and only from, the official Electrum homepage.
|
|
|
let_me_backtest_that (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 09, 2014, 08:07:36 PM |
|
Thanks for the questions and response! I'll make the sales pitch short and sweet: For someone who doesn't use fully automated systems bitconnector allows you have multiple real time charts open with saved charting parameters, 100s of built in indicators, real time alerts via email when trading conditions are met and increased order functionality like stoploss orders. About DEMA: 1. Yes, it would've been hard sit through the dead cat bounce to 1000. Systematic trading takes the same kind of discipline as discretionary trading to be successful. A mere backtest wouldn't give you that confidence. There would have to be in and out of sample tests, testing on unseen data, monte carlo simulations etc. 2. I will agree that for other methods such as filtering, trend identification and retracement trades, the DEMA may not be the best. Also, the exact combination for each of the crossovers is surely curve fitted. I merely chose the most profitable for comparison purposes. I did find the same results when researching profit factor and % profitable. Below are the top 20 optimized results that were not included in the original backtest (Jan -June 2014). SMA https://i.imgur.com/kz3qEI1.pngEMA https://i.imgur.com/unhdXp6.pngDEMA https://i.imgur.com/e7YfrCF.png
|
|
|
|
bitcoinsrus
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 09, 2014, 08:23:02 PM |
|
can anyone give me a dumb down explanation of all this (for noobs like me) greatly appreciated.
|
|
|
|
let_me_backtest_that (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 09, 2014, 10:50:39 PM |
|
I can give a quick overview of moving averages. A simple moving average merely takes the average price over the last x number of periods. So, a 5 day moving average will give the average price over the last five days. An exponential and double exponential moving average weights the most recent prices more heavily.
This is usually put on a chart in the form of a line. A moving average crossover is thought to be a buy/sell signal to indicate changes in momentum. So if the 5 day moving average crosses a 25 day moving average it indicates the prices have moved up. People use different periods of moving averages to try to better indicate profitable signals.
hope that helps.
|
|
|
|
bitcoinsrus
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 10, 2014, 01:13:26 AM |
|
I can give a quick overview of moving averages. A simple moving average merely takes the average price over the last x number of periods. So, a 5 day moving average will give the average price over the last five days. An exponential and double exponential moving average weights the most recent prices more heavily.
This is usually put on a chart in the form of a line. A moving average crossover is thought to be a buy/sell signal to indicate changes in momentum. So if the 5 day moving average crosses a 25 day moving average it indicates the prices have moved up. People use different periods of moving averages to try to better indicate profitable signals.
hope that helps.
Thanks for clearing that up, it makes more sense to me.
|
|
|
|
oda.krell
Legendary
Offline
Activity: 1470
Merit: 1007
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 10, 2014, 09:37:39 AM |
|
I can give a quick overview of moving averages. A simple moving average merely takes the average price over the last x number of periods. So, a 5 day moving average will give the average price over the last five days. An exponential and double exponential moving average weights the most recent prices more heavily.
This is usually put on a chart in the form of a line. A moving average crossover is thought to be a buy/sell signal to indicate changes in momentum. So if the 5 day moving average crosses a 25 day moving average it indicates the prices have moved up. People use different periods of moving averages to try to better indicate profitable signals.
hope that helps.
Thanks for clearing that up, it makes more sense to me. Maybe one addition: Head over to Goomboo's thread if you're intersted, he's doing a very understandable introduction to average based systematic momentum trading. You need to understand one thing though (that took me a while to really get my head around last year when I started trading): there's a tradeoff... "momentum methods", like trading based on signals from different moving averages gives you the ability to backtest your method and parameters (what let_me_backtest_that suggested in his first post). That's a huge plus. On the other hand, momentum trading means, by definition, that you "follow" the market. You will sometimes miss the early part of a huge swing because your signal isn't there yet. You will sometimes enter a trade that will end in a slight loss, because your averages whipsawed (that means: they crossed over, but then the trend never really formed, and the cross over again in the opposite direction) Where I'm getting at: average crossover methods are a great starting place for a trader, in my opinion, if for no other reason than that they really invite rigor and planning, as opposed to "intuitive" trading which usually ends in tears. On the other hand, not everyone is comfortable with mainly "reactive" trading, which trading with averages is in the end, so you need figure out what trading style works best for you.
|
Not sure which Bitcoin wallet you should use? Get Electrum!Electrum is an open-source lightweight client: fast, user friendly, and 100% secure. Download the source or executables for Windows/OSX/Linux/Android from, and only from, the official Electrum homepage.
|
|
|
Bit_Happy
Legendary
Offline
Activity: 2114
Merit: 1040
A Great Time to Start Something!
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 10, 2014, 04:13:14 PM |
|
can anyone give me a dumb down explanation of all this (for noobs like me) greatly appreciated.
Here is a simple run-down in my own words: TA (Technical analysis) is a useful set of tools, but not always accurate. Moving Averages have severe issues for traders who count on them heavily. At/near the recent lows (~$400/BTC) the moving average Bears where extremely confident they should not buy, and that was clearly the wrong "signal". By the time key moving averages give a clear signal you probably missed a large part of the move, and/or certainly didn't get the best prices.
|
|
|
|
|
oda.krell
Legendary
Offline
Activity: 1470
Merit: 1007
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 10, 2014, 04:27:45 PM |
|
can anyone give me a dumb down explanation of all this (for noobs like me) greatly appreciated.
Here is a simple run-down in my own words: TA (Technical analysis) is a useful set of tools, but not always accurate. Moving Averages have severe issues for traders who count on them heavily. At/near the recent lows (~$400/BTC) the moving average Bears where extremely confident they should not buy, and that was clearly the wrong "signal". By the time key moving averages give a clear signal you probably missed a large part of the move, and/or certainly didn't get the best prices. That one swings both ways: "At/near the $1200 ATH, the moving average avoiding bulls were extremely confident that the rally would continue forever, and didn't sell in time." The daily DEMA 33/18 suggested by OP gave a buy signal ~520 on April 15, holding since then. That's not exactly perfectly catching the bottom, but far from shabby considering that we're now more than $100 higher.
|
Not sure which Bitcoin wallet you should use? Get Electrum!Electrum is an open-source lightweight client: fast, user friendly, and 100% secure. Download the source or executables for Windows/OSX/Linux/Android from, and only from, the official Electrum homepage.
|
|
|
JustAnotherSheep
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 10, 2014, 04:54:38 PM |
|
That one swings both ways:
"At/near the $1200 ATH, the moving average avoiding bulls were extremely confident that the rally would continue forever, and didn't sell in time."
The daily DEMA 33/18 suggested by OP gave a buy signal ~520 on April 15, holding since then. That's not exactly perfectly catching the bottom, but far from shabby considering that we're now more than $100 higher.
Furthermore, I imagine Moving Average-based trading can be made far more accurate by using clever combinations of different MA crossings, as well as MACD and price-MA crossings, to get earlier signals and confirmations (very important for twitchy exponential moving averages which can sometimes give false signals). For example, price crossing daily SMA50 on May 20th in addition to the DEMA crossing would've served as stronger buy confirmation and allowed one to buy at 460-ish, at the same time of the bear trendline breakout, and the decision (to hold) would've been further reinforced by daily MACD shooting up. Of course as you say it's still largely reactive trading and personally I prefer other methods to (primarily) base my decisions on. But MA-strategies/momentum trading have the advantage of being fairly easy and straight-forward (and also easily automated for the more lazy traders ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) ).
|
Is it a bull? Is it a bear? No, it's just another sheep.
|
|
|
let_me_backtest_that (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 04:31:01 AM |
|
That one swings both ways:
"At/near the $1200 ATH, the moving average avoiding bulls were extremely confident that the rally would continue forever, and didn't sell in time."
The daily DEMA 33/18 suggested by OP gave a buy signal ~520 on April 15, holding since then. That's not exactly perfectly catching the bottom, but far from shabby considering that we're now more than $100 higher.
Furthermore, I imagine Moving Average-based trading can be made far more accurate by using clever combinations of different MA crossings, as well as MACD and price-MA crossings, to get earlier signals and confirmations (very important for twitchy exponential moving averages which can sometimes give false signals). For example, price crossing daily SMA50 on May 20th in addition to the DEMA crossing would've served as stronger buy confirmation and allowed one to buy at 460-ish, at the same time of the bear trendline breakout, and the decision (to hold) would've been further reinforced by daily MACD shooting up. Of course as you say it's still largely reactive trading and personally I prefer other methods to (primarily) base my decisions on. But MA-strategies/momentum trading have the advantage of being fairly easy and straight-forward (and also easily automated for the more lazy traders ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) ). I added a filter of the 50 day SMA. It eliminated 1 trade that resulted in a $99 loss. However, it also introduced lag on trade entries. I did not add a MACD, however, by itself it beat the DEMA with the 50 day SMA. In any case, increasing filters (i.e., adding prices above x MA and other indicators) lowers the chances that the results in the past will be representative in the future. I'm not trying to rain on anyone's parade. if you have a strategy that is working and it fits your style, then by all means make money. As far as backtesting goes, it is important to keep in mind that there are no free lunches and that adding additional filters can have costs.
|
|
|
|
falllling
Member
![*](https://bitcointalk.org/Themes/custom1/images/star.gif)
Offline
Activity: 112
Merit: 10
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 04:39:56 AM |
|
$637 is broken, $600 is coming
|
|
|
|
JustAnotherSheep
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 05:40:17 AM |
|
I added a filter of the 50 day SMA. It eliminated 1 trade that resulted in a $99 loss. However, it also introduced lag on trade entries. I did not add a MACD, however, by itself it beat the DEMA with the 50 day SMA. In any case, increasing filters (i.e., adding prices above x MA and other indicators) lowers the chances that the results in the past will be representative in the future.
I'm not trying to rain on anyone's parade. if you have a strategy that is working and it fits your style, then by all means make money. As far as backtesting goes, it is important to keep in mind that there are no free lunches and that adding additional filters can have costs.
Out of curiosity, could you backtest a combination strategy, giving buy and sell signals both at SMA10/7, DEMA33/18 and MACD 21, 28 crossings?
|
Is it a bull? Is it a bear? No, it's just another sheep.
|
|
|
YipYip
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 08:19:17 AM |
|
STill waiting on access to to your BETA ninja add-on ![Huh](https://bitcointalk.org/Smileys/default/huh.gif) EDIT: ...lolz should have checked email b4 posting ![Cheesy](https://bitcointalk.org/Smileys/default/cheesy.gif)
|
OBJECT NOT FOUND
|
|
|
let_me_backtest_that (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 02:05:02 PM |
|
I added a filter of the 50 day SMA. It eliminated 1 trade that resulted in a $99 loss. However, it also introduced lag on trade entries. I did not add a MACD, however, by itself it beat the DEMA with the 50 day SMA. In any case, increasing filters (i.e., adding prices above x MA and other indicators) lowers the chances that the results in the past will be representative in the future.
I'm not trying to rain on anyone's parade. if you have a strategy that is working and it fits your style, then by all means make money. As far as backtesting goes, it is important to keep in mind that there are no free lunches and that adding additional filters can have costs.
Out of curiosity, could you backtest a combination strategy, giving buy and sell signals both at SMA10/7, DEMA33/18 and MACD 21, 28 crossings? I am interested enough to see how this turns out I'll call it "The Follow Sheep" strategy and i'll give you the code if you want it. To be clear, do you want all of these conditions met on every entry/exit or do you want to enter/exit if any one of the conditions is met independently of the others?
|
|
|
|
JustAnotherSheep
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 03:10:44 PM |
|
Out of curiosity, could you backtest a combination strategy, giving buy and sell signals both at SMA10/7, DEMA33/18 and MACD 21, 28 crossings?
I am interested enough to see how this turns out I'll call it "The Follow Sheep" strategy and i'll give you the code if you want it. To be clear, do you want all of these conditions met on every entry/exit or do you want to enter/exit if any one of the conditions is met independently of the others? Heh, excellent name! ![Grin](https://bitcointalk.org/Smileys/default/grin.gif) I'd greatly appreciate the code if it turns out to be profitable. Actually, I'd greatly appreciate the code regardless, as then I could have a look at it to get a basic gist of whatever scripting/programming language you use, download BitConnector and start playing around with different strategies myself. Enter/Exit if any one of those conditions are met independently. I looked at charts and noticed that sometimes MACD gave better timed buy and sell signals, and sometimes the moving averages, and so got the gut feeling that a combination would get me the best of both worlds ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif)
|
Is it a bull? Is it a bear? No, it's just another sheep.
|
|
|
oda.krell
Legendary
Offline
Activity: 1470
Merit: 1007
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 03:27:34 PM |
|
Forgot to ask in the first place, but what's the cost per trade during the backtest? Given even moderate volume, slippage+fees (mainly slippage, though) easily reach 4% per trade pair. Once that is taken into account, I suspect any strategy that just cranks out one trade after another won't be profitable compared to one with less frequent trades. That said, I'd still like to see the follow_sheep results ![Cheesy](https://bitcointalk.org/Smileys/default/cheesy.gif)
|
Not sure which Bitcoin wallet you should use? Get Electrum!Electrum is an open-source lightweight client: fast, user friendly, and 100% secure. Download the source or executables for Windows/OSX/Linux/Android from, and only from, the official Electrum homepage.
|
|
|
let_me_backtest_that (OP)
Newbie
Offline
Activity: 32
Merit: 0
|
![](https://bitcointalk.org/Themes/custom1/images/post/xx.gif) |
June 11, 2014, 04:56:25 PM |
|
Out of curiosity, could you backtest a combination strategy, giving buy and sell signals both at SMA10/7, DEMA33/18 and MACD 21, 28 crossings?
I am interested enough to see how this turns out I'll call it "The Follow Sheep" strategy and i'll give you the code if you want it. To be clear, do you want all of these conditions met on every entry/exit or do you want to enter/exit if any one of the conditions is met independently of the others? Heh, excellent name! ![Grin](https://bitcointalk.org/Smileys/default/grin.gif) I'd greatly appreciate the code if it turns out to be profitable. Actually, I'd greatly appreciate the code regardless, as then I could have a look at it to get a basic gist of whatever scripting/programming language you use, download BitConnector and start playing around with different strategies myself. Enter/Exit if any one of those conditions are met independently. I looked at charts and noticed that sometimes MACD gave better timed buy and sell signals, and sometimes the moving averages, and so got the gut feeling that a combination would get me the best of both worlds ![Smiley](https://bitcointalk.org/Smileys/default/smiley.gif) I backtested from 1/1/2012-6/1/2014. Here is what we get: net profit $805, 46 trades, 60% profitable, 23% drawdown and a profit factor of 3.25. It looks like the short SMA values caused most of your losses through whipsaw trades. You can see the results on the link below: https://i.imgur.com/FFCEU5N.pngWhen you email us for bitconnector, then reference this forum post and I'll also send you the strategy code. In NinjaTrader the backtesting allows you to easily change all the variables when backtesting, so I made all the lookbacks into variables. Also, oda.krell is right about including slippage and commissions to make results the most realistic. I didn't include them, but various levels of slippage/commission can be added as well as order quantity can be changed.
|
|
|
|
|