The post Creating Better Trading Strategies — The Future appeared first on Tuned.

]]>As seen from our results in the last article, high performing strategies can result from combining two or more lesser performing ones. If you’re a creator, it could be worthwhile experimenting with your own strategies to explore whether combining some of them will yield superior results.

To help you along, Christiaan made a sample Tuned Script to combine two strategies. In the script, both are HMA crossover strategies, but you can replace them with the scripts of your own strategies, as well as the set stop loss, take profit, and combination option you’d like to use.

Here it is:

//Inputs candle_overlap_allowance = seriesOf(numInput("Max Candle Count Between Signals",2.0)) //HMA crossover 1 A1_MA_Long = intInput("A1_Long",9) A1_MA_Short = intInput("A1_Short",21) A1_SL = numInput("A1_Stop Loss",0.15) A1_TSL = boolInput("A1_trailing SL", false) A1_TP = numInput("A1_Take Profit",0.25) A1_MAL = hullma(close,A1_MA_Long) A1_AMA = hullma(close,A1_MA_Short) A1_MABuy = crossover(A1_AMA,A1_MAL) A1_MASell = crossunder(A1_AMA,A1_MAL) //HMA Crossover 2 A2_MA_Long = intInput("A2_Long",8) A2_MA_Short = intInput("A2_Short",18) A2_SL = numInput("A2_Stop Loss",0.04) A2_TSL = boolInput("A2_trailing SL", true) A2_TP = numInput("A2_Take Profit",0.2) A2_MAL = hullma(close,A2_MA_Long) A2_AMA = hullma(close,A2_MA_Short) A2_MABuy = crossover(A2_AMA,A2_MAL) A2_MASell = crossunder(A2_AMA,A2_MAL) //buy sell combo switch Order_Type= strInput("Order_Type", "Order_Type", "Order_Type", "All_Strict", ["All_Strict", "Strict_Buy_Any_Sell", "Strict_Sell_Any_Buy", "Strict_Buy_A1_Sell","Strict_Buy_A2_Sell","Only_A1","Only_A2"]) if (Order_Type == "All_Strict") { buy = and(lt(barssince(A1_MABuy),candle_overlap_allowance),lt(barssince(A2_MABuy),candle_overlap_allowance)) sell = and(lt(barssince(A1_MASell),candle_overlap_allowance), lt(barssince(A2_MASell),candle_overlap_allowance)) } else if (Order_Type == "Strict_Buy_Any_Sell") { buy = and(lt(barssince(A1_MABuy),candle_overlap_allowance),lt(barssince(A2_MABuy),candle_overlap_allowance)) sell = or(lt(barssince(A1_MASell),candle_overlap_allowance), lt(barssince(A2_MASell),candle_overlap_allowance)) } else if (Order_Type == "Strict_Sell_Any_Buy") { buy = or(lt(barssince(A1_MABuy),candle_overlap_allowance), lt(barssince(A2_MABuy),candle_overlap_allowance)) sell = and(lt(barssince(A1_MASell),candle_overlap_allowance), lt(barssince(A2_MASell),candle_overlap_allowance)) } else if (Order_Type == "Strict_Buy_A1_Sell") { buy = and(lt(barssince(A1_MABuy),candle_overlap_allowance),lt(barssince(A2_MABuy),candle_overlap_allowance)) sell = A1_MASell } else if (Order_Type == "Strict_Buy_A2_Sell") { buy = and(lt(barssince(A1_MABuy),candle_overlap_allowance),lt(barssince(A2_MABuy),candle_overlap_allowance)) sell = A2_MASell } else if (Order_Type == "Only_A1") { buy = A1_MABuy sell = A1_MASell } else if (Order_Type == "Only_A2") { buy = A2_MABuy sell = A2_MASell } //SL & TP StopLoss = iff(gt(seriesOf(A1_SL),seriesOf(A2_SL)), seriesOf(A2_SL), seriesOf(A1_SL)) TakeProfit = iff(gt(seriesOf(A1_TP),seriesOf(A2_TP)), seriesOf(A2_TP), seriesOf(A1_TP)) conf_stopLossPercent.set(StopLoss) conf_takeProfitPercent.set(TakeProfit) conf_takeProfitTrailingPercent.set(seriesOf(0.0)) //plot // plot(AMA, "kamaShort", "#ff0000", 1) // plot(MAL, "smaLong", "#42f682", 1) // plot(LRR1, "LRR1", "#0000ff", 1) // plot(LRR2, "LRR2", "#9999ff", 1) // //plot(LRR, "LRR", "#9999ff", 1) //signal Push out(signalIf(buy, sell))

Feel free to reach out on our Discord if you need any help using this script to combine your strategies!

Just for fun, let’s see how this specific correlated pair performs over the batch test period (from May 21, 2021 to December 15, 2021):

Strategy | Profit/Loss | Profitable Trades | MDD | # Trades | Profitable Months | Average Lose Month | Average Win Month | Average Monthly Profit |

Combined Pair | 180.97% | 51.97% | -21.70% | 127 | 75% | -1.49% | 17.02% | 14.47% |

Strategy 1 | 12.72% | 29.71% | -46.75% | 271 | 50% | -10.54% | 12.66% | 2.59% |

Strategy 2 | 34.22% | 51.97% | -42.17% | 489 | 50% | -10.33% | 16.71% | 5.28% |

As you can see, we’re using different metrics to evaluate these strategies as we did in the last article. That’s because these metrics are directly from the Tuned editor! Nonetheless, we see the combined pair significantly outperforming each individual strategy, with half the Maximum Drawdown and nearly 3x the average monthly profit of the best of the two. The individual strategies had profit factors of 1.04 and 1.07, while the combined pair takes it up to 1.63. Moreover, averaging 18.6 trades a month, we are likely not overfitting on the data.

Finally, here’s how the combined pair does long term over a backtest:

Not too shabby, right? But before you get started, you might want to consider…

From my research, I’ve seen that most of the time, it’s the strategies with different creators that correlate well together. Each creator has a unique way of thinking about and building strategies and by collaborating with each other, even better results can be achieved. It’s like finding confluence, but between different minds!

Tuned has many incredible creators and the following are just a handful of them:

If you’re a creator, we encourage you to reach out to other creators on Discord and perhaps strike up a collaboration!

Also, consider broadening your scope. For instance, trend trading strategies such as those using moving averages or momentum might correlate the best with strategies using other indicators like Bollinger Bands. Looking at other concepts can improve your strategies.

Throughout the lifetime of this research project, the Tuned team has been excited about its implications. While we’re currently focusing on other features that will be going live early 2022, the team really likes the idea and it’s something we’re keeping in mind for later this year.

A sneak peek into what we’re thinking: the idea is to enable strategy creators to opt-in to allow their signals to be used by other creators and receive a profit share in return. Obviously, it’s still very much in the works and will likely change, but we’re just as excited as you are to see what comes of this research.

I hope you’ve enjoyed reading about the work I’ve been doing at Tuned to create better trading strategies. Thanks to the help of many Tuners, especially Christiaan, I’ve been able to do some really incredible work and share it with you all. Whether you’re an experienced strategy creator or just reading to learn more about the whole world of quantitative analysis, I hope you’ve learned a thing or two. Happy trading!

The post Creating Better Trading Strategies — The Future appeared first on Tuned.

]]>The post Creating Better Trading Strategies — The Results appeared first on Tuned.

]]>

Continuing from the second article, where I discussed the clustering of buy signals, we’re now ready to get into the meat of things: finding correlated groups. The idea is to find two or more strategies that when combined, give much stronger performance than each would achieve alone. We’ll start with combining just two strategies together and deciding metrics to measure their performance, before moving to larger correlated groups. Let’s jump right in!

In our last article, we concluded that simply pairing random strategies and taking their correlated buy signals would not yield the results we wanted. Instead, we must combine strategies systematically. Here’s the process we used to find correlated pairs:

- Find all possible pairs of strategies
- For each pair, go through every cluster and find correlated buy signals (if they exist)
- Calculate performance metrics for each pair from correlated buy signals

We know how to do steps 1 and 2. However, what are the performance metrics we’ll use for step 3?

These metrics will allow us to compare our strategy pairs with the individual strategies they came from, and compare correlated pairs with one another. Here’s what they are:

Performance Metric | Description | Why it’s useful |

Profit Factor* | Gross Profit ÷ Gross Losses | Are we winning more or losing less? |

Average Net Profit* | Average profit across all trades | On average, are we winning more for each trade? |

Profitable Trades | Percentage of total trades that are profitable (see our last article) | Is the proportion of winning trades increasing? |

Average Profitable Trade* | Average profit across all profitable trades | Are our winning trades earning more? |

Average Unprofitable Trade* | Average profit across all unprofitable trades | Are our losing trades losing less? |

There’s a couple of notes to make. First, some readers might find it strange that I haven’t included some of the other conventional metrics, like Maximum Drawdown (MDD). Given the method I’m using to combine strategies, calculating MDD would be quite difficult and so I decided to exclude it from the list. However, be mindful that the results presented will not include this measurement of risk. Second, the metrics denoted by * are not calculated conventionally. Rather than using the actual profit in currency, we use the compounded percentage profits. Thus, these metrics are measured with percentages.

We calculate percentage profit with the following formula:

For the buy price, we must always take the last buy signal that occurs, since we’ll only know it’s a correlated buy signal if both fire. However, with sell signals, we can be pickier.

We have 4 options:

- First: we take the price of the first sell signal that fires from either of the two strategies
- Average: we average the prices of both sell signals, effectively selling half of our exposure at every sell signal
- Strategy 1: We denote one of the strategies as strategy 1 and take only the prices of the sell signals of that strategy, ignoring the other strategy.
- Strategy 2: Same as Strategy 1 but for the other strategy.

So, when looking at the metrics from strategy groups, we must look at all 4 options of sell signals and can see which sell signal performs the best.

After performing all 3 steps, calculating the 5 performance metrics for all 4 options, we can see which strategy pairs perform the best. Here are our best performing correlated pairs:

Note: to protect the privacy of our creators and their strategies, the individual strategies that make up the correlation pairs are kept unidentified.

**Correlated Pair 1: **

Strategy | Profit Factor | Average Net Profit | Profitable Trades | Average Profitable Trade | Average Unprofitable Trade |

Correlated Pair (First) | 6.68 | +1.06% | 68.33% | +1.83% | -0.59% |

Strategy 1 | 1.01 | +0.01% | 49.16% | +2.01% | -1.93% |

Strategy 2 | 1.09 | +0.07% | 51.65% | +1.69% | -1.65% |

For these two strategies, the first sell gave the best performance across all four options of choosing sell signals. As we can see, the profit factor and average net profit are significantly higher in the correlated pair than in the individual strategies. This can be attributed to its higher percentage profit, giving it a higher percentage of winning trades. Furthermore, while its average profitable trade isn’t the highest, it has a comparably low average unprofitable trade, so it loses less for each loss-inducing trade (-0.59% as opposed to -1.93% and -1.65% for the individual strategies).

Let’s take a look at another one…

**Correlated Pair 2: **

Strategy | Profit Factor | Average Net Profit | Profitable Trades | Average Profitable Trade | Average Unprofitable Trade |

Correlated Pair (Strategy 2) | 2.60 | +1.69% | 63.01% | +4.36% | -2.85% |

Strategy 1 | 1.15 | +0.25% | 53.50% | +3.60% | -3.61% |

Strategy 2 | 1.30 | +0.33% | 51.42% | +2.78% | -2.25% |

This correlated pair takes sell signals only from the second strategy. Again, we see significant improvements in profit factor and average net profit, although not as drastic as in our previous correlated pair. Again, we can attribute this to the correlated pair’s higher % profit. However, we also see a significant increase in the average profitable trade, telling us that each winning trade is netting us more on average, a mean of +4.36% per profitable trade.

These are already pretty incredible numbers, but what if we kick it up a notch?

So far, we’ve been dealing with correlated groups with two strategies. Now, let’s increase the number of strategies in a group. The process of finding signals is the same, but instead of taking every pair like in step 1, we take every triple or quadruple.

However, note that as the number of strategies in a group increases, it becomes harder to find clusters where all strategies fire buy signals. To illustrate the point, correlated groups with 2 strategies have on average 115 trades, as compared to 71 and 50 trades for correlated groups with 3 and 4 strategies respectively. This leaves us prone to overfitting on limited data as we increase the number of strategies in a group.

So, we only consider strategy groups that trade at least once every 3 days. Furthermore, we only look at strategy groups up to a size of 4, as going further than that will produce unhelpful conclusions. Let’s take a look!

**Correlated Triple 1: **

Strategy | Profit Factor | Average Net Profit | Profitable Trades | Average Profitable Trade | Average Unprofitable Trade |

Correlated Triple (First) | 7.58 | +1.10% | 69.49% | +1.83% | -0.55% |

Strategy 1 | 1.01 | +0.01% | 49.16% | +2.01% | -1.93% |

Strategy 2 | 1.09 | +0.07% | 51.65% | +1.69% | -1.65% |

Strategy 3 | 0.97 | -0.02% | 51.31% | +1.74% | -1.88% |

If you’ve noticed, this correlated triple has the same strategies as our first correlated pair, but includes an additional strategy. We see improvements across profit factor and average net profit, mostly due to the higher percentage profit. However, it’s a lackluster improvement over the correlated pair, which was a strong performer already.

**Correlated Triple 2: **

Strategy | Profit Factor | Average Net Profit | Profitable Trades | Average Profitable Trade | Average Unprofitable Trade |

Correlated Triple (Strategy 1) | 2.66 | +1.77% | 65.65% | +4.31% | -3.09% |

Strategy 1 | 1.30 | +0.56% | 55.56% | +4.35% | -4.18% |

Strategy 2 | 1.14 | +0.23% | 48.09% | +4.01% | -3.27% |

Strategy 3 | 1.90 | -1.22% | 58.78% | +4.37% | -3.29% |

Again, we see improvements across profit factor and average net profit, largely thanks to a higher percentage profit and lower average unprofitable trade.

As we’ve seen, performance improves slightly as we increase from pairs to triples. However, performance actually decreases as we move from triples to quadruples. For example, the best performing correlated group with 4 strategies has a profit factor of 7.55 and a average net profit of +1.10%, a slight decrease from Correlated Triple 1. So, it seems that triples are the sweet spot here, although pairs perform fantastic as well.

Today, we went over the process of finding correlated groups and saw them in action, with some pretty phenomenal results! In the next and final article, we’ll wrap it all up, discussing next steps, potential ideas, and how you can apply these findings to your strategies. Until then, happy trading!

In our last blog post, I introduced my project to combine buy signals from different strategies to potentially generate higher returns for all traders on …

Picture this: the new iPhone 17 Ultra Pro Max just dropped, and you’re debating whether or not to switch up your mobile device. The new …

And here we have it: the last installment of the data science article series! In our previous article, we created some correlated clusters and came …

The post Creating Better Trading Strategies — The Results appeared first on Tuned.

]]>The post Creating Better Trading Strategies — The Process appeared first on Tuned.

]]>Over the past summer, I’ve investigated the following question: if executing a buy order only when two or more strategies indicate a good time to buy, can we deliver higher profits than that of each individual strategy? Our first step is figuring out how to group buy signals from different strategies occurring around the same time, which I’ll refer to as *clustering*.

Now you may be asking…

Good question! In the context of Tuned strategies, a buy signal initiates a trade position, and a sell signal closes it. For one, it’s more worthwhile to focus on clustering buy signals since it doesn’t require an open position. To cluster sell signals, positions from two or more strategies would have to be open first, which limits the number of signal combinations we can make.

Furthermore, it makes more sense logistically to focus on buy signals. When multiple buy signals from a set of strategies happen around the same time, we execute a buy order. From there, we either take the earliest sell signal of those strategies or the sell signal of the strategy with the best sell signals. This reasoning doesn’t work the other way around: it’s possible we could create an open position, but not have a cluster of sell signals to close it.

As a result, I decided to focus solely on clustering buy signals first, and then use those buy signals to figure out what the optimal sell signals are. But before we dive into that…

Trading strategies on Tuned run on candles (also known as candlesticks). Here’s a candle:

A candle represents the price movements of an asset over a specified length of time — e.g., 30 minutes, 1 hour, or even 1 day. In our case, this is a pair of cryptocurrencies. Each candle represents four values, OPEN, CLOSE, HIGH, LOW, and the price movement direction. Whether the open price was higher or lower than the closing price is indicated using the color of the candle. Traditionally, the color is green when CLOSE price > OPEN price and red when OPEN price > CLOSE price. Here’s the same candle again:

On our platform, a blue candle means the CLOSE price was higher than the OPEN price, and a red candle denotes the opposite.

By using candles, we can show the price movements of an asset in a simplified manner:

Why do candles matter? It’s because all Tuned strategies trade on candles, and it’s how we’ll combine their signals!

Here’s what the signals of a Tuned strategy look like:

Disregarding stop loss and take profit, strategies generate signals only at the start or end of their candles. As such, the duration of a strategy’s candles indicates how frequently it can buy or sell. For example, a strategy with 15-minute candles can trade on a minimum of 15-minute intervals.

To approach the problem of clustering buy signals, I’m going to pick a candle size to allow us to define what a cluster represents. As an example, let’s choose 30-minute candles. Now, if two or more strategies generated a buy signal on the same 30-minute candle, we’ll say those signals are in the same cluster. On the other hand, if two signals occur on different 30-minute candles, even if they’re placed less than 30 minutes apart, they will **not **be a part of the same cluster:

With that established, there’s a clear path ahead: I’ll start by picking the candle size to define our clusters, and then code an algorithm to cluster our buy signals. Finally, I’ll end off with some preliminary results!

Here’s a histogram of the candle sizes of different live strategies trading on BTC:

Out of the 762 BTC strategies trading on Tuned at the time of writing, 30% use 60-minute candles and ~20% use 15-minute candles. Strategies with 30, 90, and 120-minute candles represent around 10% each.

I decided to go with 60-minute candles to strike a good balance between smaller and larger candles and likely capture most clusters (we’ll increase the candle size if we’re unable to find many clusters down the line).

Next up, I coded an algorithm to cluster buy signals. On a high level, I first queried all the buy signals of strategies trading on BTC from the orders data in our data warehouse. From there, I iterated through all the signals and placed them in the correct 60-minute cluster — i.e., if a signal fired at 2:32 PM on August 20, it would be placed in the 2-3 PM cluster on that date (Tuned candles begin at midnight UTC every day). We also implemented a 1 minute buffer between candles to allow tolerance for signals fired after the CLOSE or before the OPEN of a candle, i.e., a signal fired at 3:00:25 AM joins both the 3 AM and 4 AM hourly clusters.

After running the clustering algorithm on 80,000 or so buy orders from BTC strategies, I began analyzing the results by visualizing the frequency of different cluster sizes. My goal was to confirm if we had enough buy signals falling into clusters to determine whether the 60-minute candle size was large enough.

Great news! Since there are only a little over 600 signals on their own candle from the total 80,000 signals, we know we definitely have enough clusters, so we’ll keep the 60-minute candles moving forward. We might even consider decreasing it.

Now how did the quality of buy signals differ between cluster sizes? We’ll explore different ways to measure cluster performance in the next post, but in the meantime, let’s just look at percent profitable.

*Percent profitable: the number of profitable trades divided by the total number of trades — i.e., the probability of “winning”. When percent profitable is 50%, the number of winning trades is equal to the number of losing trades.*

It’s glaringly obvious that we will not attain higher returns by blindly clustering buy signals. Just like with buying iPhones, not everyone’s decision to do so will be the right one, or at the right time. Instead, we’ll have to cluster systematically, finding specific trading strategies that synergize well and leveraging their specific strengths to generate higher returns.

Today, we went over candles and how Tuned strategies trade on them, as well as my process to cluster buy signals: starting with selecting a candle size for clusters, then executing an algorithm to perform the clustering, and ending off with some initial results! In the next post, I’ll be finding groups of strategies that give higher profits when their buy signals are combined, and determining ways to measure their performance. Stay tuned!

Welcome back, data science fans!
Continuing from the second article, where I discussed the clustering of buy signals, we’re now ready to get into the meat …

The post Creating Better Trading Strategies — The Process appeared first on Tuned.

]]>The post An Intro to Creating Better Trading Strategies appeared first on Tuned.

]]>Now, what if a friend was buying it? Let’s say he’s a frugal fellow but is extremely impressed with this iPhone in particular. Would that sway you to buy? How about if multiple friends or family members also made the purchase?

**What if your purchasing decisions systematically took into account those of your peers?**

Over the past summer, I’ve been working on this exact idea, but towards trading algorithms instead of Apple products — and I’ve got some surprising results to show you all over the next few blog posts!

But first…

As a part of the Data Science (DS) Team here at Tuned, we provide insights, support our engineering team, and explore potential opportunities for innovation. We’ve grown to a team of 3 members in just a couple of months, with the goal of providing greater value to Tuned and all the traders we service.

*If you’re not familiar with Tuned, our platform is used by thousands of traders to create and run high performing strategies, who can then provide access to trading signals generated from those strategies with other traders (i.e., investors) for a fee.*

The DS team started off with Christiaan, our Chief Information Officer. Christiaan’s been with Tuned since 2019, designing our platform and planning our roadmaps. He also helps out the community (you’ve probably seen him around our Discord), works on data science, requirements, operational excellence, and supports our day-to-day management of the business.

Next up, we have Alec, our Director of Analytics. He’s been spearheading the development of our data stack, which started with the launch of our Redshift analytics warehouse. He’s implementing a number of tools to increase data access across the organization that support our product, operations and growth initiatives.

And then there’s me! Hi, I’m Albert and I’ve been a Data Science Intern here at Tuned for the past 2 months. Along with supporting our DS team by generating visualizations and writing queries, I’ve been working on an exciting project to investigate how we can improve the performance of Tuned strategies!

Say we have two automated trading strategies, strategy A and strategy B. Each strategy is backed by a script (think of an instruction manual), which analyzes market data and tells the strategy when to buy and when to sell. These decisions for when to buy or sell are called signals. For example, when a script decides to fire a buy signal, the strategy will execute a buy order of, say, Bitcoin. Strategy creators aim to program scripts that generate profitable signals — ones that buy low and sell high.

Here’s the hypothesis: what if we only executed a buy order if both strategies A and B fired a buy signal at (or around) the same time? Just like our friends who also decided to buy the new iPhone, what would happen if we only buy when other parties are also buying? Could this give us a better return?

That’s the question I’ve been tackling during the past 8 weeks, by coding clustering algorithms and diving into the data we’ve collected…

As mentioned earlier, Alec helped set up our data analytics warehouse on Redshift. To answer my inquiry question, I’ve been querying data from Redshift, from buy and sell signals to market data and orders from strategies, via the HeidiSQL client.

While our warehouse stores a ton of data, there’s a lot of data we **don’t** collect either. We don’t have access to the proprietary code written by strategy creators — script ownership rests solely with their creators. The warehouse also doesn’t store personally identifiable information (PII) like names or emails. We value the privacy and efforts of our creators and only use the data we need to provide a better experience to all users.

At Tuned, we strive to help everyone attain higher returns by helping creators build superior algos. We do this by investing in R&D and innovating on the cutting edge of financial markets and algo trading.

My project, to combine signals from different strategies to improve performance, has the potential to further separate Tuned from any other platform. If we can discover strategies that synergize well, we’ll be able to create more powerful tools for creators to leverage, which will lead to better-performing syndications for investors! As such, we believe that every party involved benefits from these efforts.

For transparency, I’ve been working on a purely exploratory analysis. We haven’t applied the findings of this project yet, nor have we made money through this in any way. Part of turning this research into a product will be an “opt-in” system, allowing every creator on Tuned to participate. We are currently still deepening our research before starting any implementation. Stay tuned for future developments and potential applications in our upcoming posts!

In the next article, I’ll be diving deep into my analysis and present some exciting results, including unexpected pairs of strategies that combine together for some pretty terrific returns. See you there!

The post An Intro to Creating Better Trading Strategies appeared first on Tuned.

]]>