Demo of first complete TradingView Strategy called BunnyIntroducing Bunny - the groundbreaking TradingView strategy that promises to revolutionize the world of online trading. Developed by a team of experts in the field, Bunny offers a comprehensive and innovative approach to trading by combining advanced technical analysis tools with a user-friendly interface. With its intuitive design, Bunny allows traders to easily create, test, and deploy custom strategies tailored to their unique trading preferences. Whether you are a seasoned investor or just starting in the world of trading, Bunny provides users with a fully immersive experience that unlocks the full potential of TradingView's platform. With its array of powerful features and comprehensive market data, Bunny offers the necessary tools and insights to analyze market trends, make informed trading decisions, and maximize profits. Embark on a new trading journey with Bunny and unlock the doors to success in the ever-evolving world of financial markets.
Strategytester
Testing a Youtube MACD StrategyIn previous articles, I’ve tested moving average crossovers and bounces.
But I didn’t test this famous (or infamous?) indicator related to them…
The MACD.
When I saw a video from TradingLab on Youtube called “BEST MACD Strategy,” I was curious to test his approach.
What’s a MACD Daddy-o?
It stands for Moving Averages Convergence Divergence. It’s meant to help us see momentum in the market.
So we take a shorter-duration moving average and pair it up with a longer one.
We then graph the difference between the two as its own line.
We also plot an MA of the difference, called the “signal” line.
When the signal line crosses over the difference line, we might be seeing a shift in direction.
The farther the signal line pushes away from the other, the stronger the momentum is in that direction.
Note: most charting software, including TradingView, also shows the difference as bars (a histogram).
So how are we gonna test this thing?
The Trading Truth Test Setup
We’re keeping the market and the test period the same as some of the previous tests, for easier comparison.
(The TradingLab video just says MACD works in many markets and timeframes, without limiting it to one for testing.)
Market: the S&P 500 index (using SPY to trade it, assuming SPY is exactly 1/10th the S&P 500 Index price)
Timeframe: Jan 2, 2008 to March 28, 2023
Bar interval: 1 hour
Moving averages: Unlike previous tests, where we used simple moving averages, we’re using exponential moving average here to weight recent prices more.
We use a 200 exponential moving average for overall trend direction.
For the MACD, we’re using the classic 12 bars and 26 bars to see the difference between them. And we’re the normal 9-bar MA of that difference as the signal line.
Starting Equity: $ 25,000
Max % of Equity Per Trade: 3%
Commissions, fees and taxes. To keep things super simple, we’re assuming these are all zero.
Our Test
When we get a MACD crossover between the signal line and the difference line, we look to go long.
But we only go long if:
the last closing price is above the 200 MA, and
When an upside MACD crossover (the signal line crossing up through the difference line) happens below its zero line (the lower half of the plotted indicator area).
We do the opposite to go short…
We short when price closes below the 200 MA and we get a downside MACD crossover above the zero line.
Our stop loss is 1 penny past the 200 MA value when entering the trade.
And our take-profit price is the difference between the entry price and the 200 MA (on entry) multiplied by 1.5. That’s the suggestion in the TradingLab video.
Note: The Youtube video suggests using support and resistance as another filter to avoid choppy markets. But there aren’t clear rules given, so I didn’t do that.
The Test Results
The test ended at $ 30,401.39, up 21.6% with a 46.9% win rate.
The biggest loss from the initial $ 25,000 deposit was $ 270.85, a 1.1% loss.
The maximum losing streak was $ 800.22 or 3.0% (from $ 26,908.66).
That said, the buy-and-hold return was 173.1%.
Quite a reward for sitting on your hands, especially given the tax advantages from long-term capital gains.
Note: I did this analysis in a spreadsheet, with exported TradingView data. If you see any errors, please let me know.
What Test Tweaks We Could Make
We could identify rules on when to stay out of the market.
MACD strategies, like many, get chopped up in sideways price action.
Some other MACD settings might also be interesting to test. We used only the most common settings here.
What would you test? And what else would you like to see tested?
Comment below!
Which Moving Average Strategy Crushes MA Crossovers? This...If you read last week’s article, you saw results for the famous (or infamous!) moving average crossover.
It bombed vs buy and hold over the last 10 years, even when using take-profit and stop-loss levels.
So, how do moving average bounces perform with the same exit levels?
That’s what we’re testing today…
The Trading Truth Test Setup
Our setup is the same as last time, except we just need one moving average.
Market: the S&P 500 index (using SPY to trade it)
Timeframe: Jan 1, 2013 to January 31, 2023
Bar interval: 30 minutes.
Moving averages: 50 bars (simple moving averages, meaning every bar gets equal weight, unlike with exponential)
Starting Equity: $25,000
Max % of Equity Per Trade: 3%
Commissions, fees and taxes. To keep things super simple, we’re again assuming these are all zero.
How Is “Bounce” Defined?
Traders look for ricochets off moving averages in a bajillion ways.
Let’s be real: most just eyeball charts without real rules.
That won’t work for rigorous renegades like us, though. :-)
So, for Test A, here’s how we defined a bounce when price is above the MA:
A price bar’s low is above the moving average
The next price bar’s low touches or pierces the MA for one bar. (A close below the MA is ok.)
The bar touching or piercing the MA can’t go more than 0.5% below the MA
The next bar’s low must again be above the MA.
Flip these rules for a bounce when price is below the MA.
I know, I know… many bounces don’t happen until 2 bars (sometimes more) hover on or below the MA. We're keeping the criteria here simple.
We define Test B the same way, except with an extra filter:
The 50-bar MA needs to be sloping up at least 0.5% over the last 25 bars for long trades (and -0.5% or less for short trades).
Alrighty, now, let’s check out the results…
The Test Results
Like with the MA crossovers test before, let’s first look at how plain ol’ buy and hold did over the same period.
If you parked your cash in the S&P 500, your money would be worth 2.9 times as much by the end. Pretty good.
So how did Test A do?
The ending equity after 10 years was $40,112.74, 1.6 times your money with 24.27% max drawdown.
Test B, in which we only took trades if the MA was sloping (trending) enough, we ended with $43,149.00, for a 1.7x return with only 17.75% max drawdown.
That makes the return on risk much better than Test A.
Yet, while these returns beat the pants off of our MA crossover tests, boring old buy and hold still whooped them both.
What Would You Change About This Bounce Strategy?
Trade a different market?
Longer or shorter time frame?
Tweak how a bounce is defined?
Comment below to share. Also, please let me know: what else do you want to see tested?
Trading Truth Test: Do MA Crossovers Really Work?If you’ve ever sat up late at night watching tv, you may have seen an infomercial for software to become a day trader.
They make trading sound so simple. Buy when a green arrow appears on the chart. Sell when a red arrow pops up.
You’re snickering right now because you already know it doesn’t work.
Yet so many traders talk about moving average (MA) crossovers in a similar way.
Put a shorter time period MA (like 21 bars) on a chart and wait for it to cross above longer one (say, 50 bars) to buy. Do the opposite to sell.
So how well does it really work?
Let’s jump in and find out…
Testing the Fabled Moving Average Crossover
My 21/50 moving average crossover example above is a semi-common one people use.
Of course there are others, like the 5/8, the 8/13 and the 13/21.
5, 8, 13 and 21 are all Fibonacci numbers, so people believe they have special powers.
That’s probably a self-fulfilling prophecy since so many people use them. But that’s a test for another day.
On to the rules!...
The Trading Truth Test Setup
Market: the S&P 500 index (using SPY to trade it)
Timeframe: Jan 1, 2013 to January 31, 2023
Bar interval: 30 minutes.
I chose 30-minute bars instead of the 2-minute or 5-minute bars many day traders use, just to smooth trends more. The less we can get caught in chops, the better.
Moving averages: 21 and 50 bars (simple moving averages, meaning every gets equal weight, unlike with exponential)
Starting Equity: $25,000
Max % of Equity Per Trade: 3%
Commissions, fees and taxes. To keep things super simple, we’ll assume these are all zero.
That’s borderline-realistic if you’re trading in a retirement account with a broker not charging commissions (you’d still have to pay exchange fees).
The A/B Test Rules
Rules for Test A
This is the classic moving average crossing strategy.
Whenever the 21 MA crosses above the 50 MA, buy.
And every time the 21 MA crosses below the 50 MA, sell.
That means, we exit whatever trade we’re in when we get the opposite signal… and then jump in going the other direction.
Easy fo sheezy.
Rules for Test B
Everything is the same here, except for when we’ll take profits and losses.
For this bad boy, we’re gonna use the 21-bar average true range (ATR) as both a trailing stop-loss and a trailing take-profit.
Specifically, we’re using twice the 21-bar ATR (based on the previous bar’s closing price) for extra wiggle room.
If we’re still in a trade when we get a new entry signal (MA crossover), we don’t take the trade. ‘Cause we’re rebels like that.
One other quirk for Test B: if we hit a take-profit level in the same bar as a stop-loss target, I assumed we took the profit first. It didn’t make much difference overall, as we’ll see…
The Test Results
Before we see how Test A did vs Test B, the real baseline is just ye ol’ Buy and Hold.
If you plunked your money into the S&P 500, your money would be worth 2.86 times as much by the end. Not bad for doing nada.
So how did Test A do?
No bueno. The ending equity after 10 years was only $25,091.74, which is barely breakeven. The one bright spot is the max drawdown, at 5.0%.
It’s not hugely surprising, since MA crossover strategies are highly prone to losses when the market is chopping around instead of trending. And the market sloshes around way more than it trends.
This pure strategy (only exiting a position on the next crossover) also tends to give back most profits, since it waits so long to exit.
Given the take-profit targets and trailing stop-losses in Test B, how did we fare there?
We ended with $27,261.39, a 9.0% return.
Definitely better, especially given the 1.9% max drawdown, but nowhere near as good as buying and holding — especially when you factor in all the trading you’d have to do.
What to Test Next
Using some kind of trend indicator, like Super Trend or Linear Regression, to filter entry signals could help reduce losses.
Picking a different market might also get us better results. For example, I saw someone on Youtube say the EUR-GBP forex market works well for MA crosses.
Testing longer-period moving averages would also smooth the price action more and be less likely to cross as much in ranges.
HOW-TO: Compare Different Strategies With Strategy TesterMy good friend Moses emerged from the cloud and declared “I have beaten the Nasdaq 100 by 1,100% over the last 24 years.”
I double and triple-checked his numbers, and goodness me he was right.
“How did you achieve that Moses!” I exclaimed.
“It was achieved using the application of mathematics and technical analysis” Moses retorted.
“But what did you do specifically,” I asked.
“I managed to avoid all the major stock market crashes and entered the Index ETF lower than when I sold it. This compounded my long-term gains tremendously” he cried.
MOSES ( M arket O utperforming S tock E TF S trategy) is of course my affectionately named TradingView Strategy Pine Scripts/Algos.
TradingView the New King Of Backtesting
I have been working on backtesting systems for the last 14 years. I have used many competing services, but TradingView is my new favorite tool.
Why?
TradingView has enabled me to backtest many scenarios using their excellent Pine Script. I am not a developer, but Pine Script is super easy.
Backtesting & Strategy Testing Takes Time… But TradingView Makes it Quicker.
Creating a strategy that tests for solid results takes a lot of time and effort. But don’t get disheartened. Start with indicators you believe in and test them. Do they really work? How often, what is your success rate. How long is each trade? How often do you trade? What is your drawdown? What is your Sharpe & Sortino ratio?
Luckily TradingView makes this process really fast, the speed of calculating the results of a test is mind-blowing. Seriously, it’s a platform that can perform 5, 6, 7, 8 strategies side by side over 24 years in the blink of an eye.
How did Moses Perform?
I have 3 MOSES strategies which you can see on the chart. All three beat the Nasdaq 100, but one really beat it hard. The “Buy on Bull Sell on Bear” strategy made $2.88 million on $100K invested in 1997, vs. $1.76 million for a “Buy and Hold” strategy, a 1,100% difference on $100K invested.
This long-term performance was with only 12 trades in 24 years with a 67% success rate. How do I know this? TradingView tells me in its strategy tester reporting.
Moses tells me many things:
When we are in a solid Bull Market (Green Dots)
When we are in a Bear Market (Red Dots)
When we have a Shock to the Market (Shock Label)
When we have a Catastrophic Event (Red Catastrophe Label)
When to buy back in early, before the full bull market resumes (yellow dots)
Thanks to TradingView
Thanks to TradingView, I have a platform where I can rapidly test ideas and see if they work in the past.
I can check to see if a new fancy indicator really works or if it is just hype. (95% are hype)
If you are not backtesting strategies, then how do you know if they have a chance to work in the future?
Walking the Path
We all start as beginners. We think it is easy to make money. Then we experience a large crash and we lose a lot of money. Then we leave the market. If you persevere, you will try to build your knowledge and experience. If you go 23 years down that path, you realize that system and strategy development using backtesting is essential to making repeatable money.
Strategy Development Advice
“You can try to out-compete the hedge fund algorithms by day trading, but that is near impossible. You cannot out-arbitrage a supercomputer.”
You can, however, develop your own strategy that works over weeks, months, or years, and you can really make good profits.
Notes on the Chart
I run 5 scripts, 3 Moses Strategies + 1 Buy & Hold strategy for comparison (lower panes), and the MOSES Signals 2.0 in the price chart.
The chart is Weekly and from 1997 to today.
Note on Strategies.
Systems may not work in the future as they have worked in the past. There is no guarantee of future returns. Moses is a long-term strategy that works over years, not a day trading strategy. Moses worked in the past on major US and European stock market indices, it does not work with India or Chinese markets, no Strategy is perfect, not even Moses. Moses scripts are private.
Follow me if you like the post, and if you want to see my next post, the “10 Commandments of Moses” 😊
Any questions you have, let me know in the comments.
Barry
Common TradingView Mistakes and Friendly TipsIn this video idea, I share some common mistakes I see people make when looking at and interpreting strategies and indicators on TradingView that may impact their profitability when trading. I also share some helpful tips on how to avoid falling for other people's mistakes by getting sucked into public strategies that seem too good to be true, and also how to use some of the more undervalued features on TradingView to help improve your experience.
Using the Strategy Tester to Evaluate a StrategyThis video idea explains how to use the strategy tester on TradingView to evaluate the performance of your strategy. We go over all of the data presented for you regarding your strategy, and if we make mistakes along the way you can always check out the TradingView help section that is specifically for the Strategy Tester.
I highlight the overview of your strategy, dive into the details of the performance summary for your strategy, and show how we can review all of our trades including our commission paid.
Finally, we show how changes to the strategy can alter your Strategy Tester results and how accounting for commission(fees) and selective testing windows can alter perceptions on strategies.