INVITE-ONLY SCRIPT

A Physicist's Bitcoin Trading Strategy

Zaktualizowano

1. Summary

This strategy and indicator were designed for, and intended to be used to guide trading activity in, crypto markets, particularly Bitcoin. This strategy uses a custom indicator to determine the state of the market (bullish vs bearish) and allocates funds accordingly. This particular variation also uses the custom indicator to determine when the market is significantly oversold and takes advantage of the opportunity (it buys the dip). The specific mathematical formula that is used to calculate the underlying custom indicator allows the trader to get in before, or near the start of, the bull trends, and get out before the bear trends. The strategy's properties dialogue box includes many display settings and parameters for optimization and customization to meet the user's needs and risk tolerance; this is both a tool to gauge the market, as well as a trading strategy to beat the market. Guidelines for parameter settings are provided. A sample dataset of backtest results using randomized parameters, both within the guidelines and outside the guidelines, is available upon request; notably, all trials outperformed the intended market (Bitcoin) during the 9-year backtest period.



2. The Indicator and Strategy

2.1. The Indicator
A mathematical formula is used to determine the state of the market according to three different "frequencies", which, for lack of better terminology, are called fast, moderate, and slow indicators. There are two parameters for each of the three indicators, one called response time and the other is a simple look-back period. Finally, four exponential moving averages are used to smooth each indicator. In total, there are 18 different levels of bullishness/bearishness. The purpose of using three indicators, rather than one, is to capture the full character of the market, from a macro/global scope down to a micro/local scope. I.e. the full indicator looks at the forest, the trees, and the branches, simultaneously.

2.2. The Strategy
The trend-trading strategy is very simple; there are only four types of orders: 1) The entire position (e.g. all bitcoins held) is sold (if it hasn't already been totally sold) when the indicator becomes maximally bearish, 2) When the movement of the indicator is in the bullish direction, the strategy dollar-cost-average (DCA) buys at an exponentially decreasing rate, i.e. it buys more in the early stages of the transition from bear->bull. 3) When the indicator is maximally bullish, it goes "all-in" † (if it hasn't already gone all-in), i.e. it converts all available cash into the underlying security/token. And, 4) when the movement of the indicator is in the bearish direction, the strategy DCA sells (again, exponentially decreasing) to get out quickly. No leverage is used in this strategy. The strategy never takes a short position.

A second "buy-the-dip" strategy is also used, and it is the synergy of these two strategies, together, that is responsible for most of the outperformance in the backtests (this strategy handily beats the non-dip-buying variation in backtests). To do this, the custom indicator is used to determine when the market is significantly oversold on a short-term basis, and the strategy responds by DCA buying. However, unlike the DCA buying during bull/bear transitions, the buy-the-dip DCA buying increases with time. Specifically, within each candle that is short-term oversold, the strategy converts 10% x # of candles since becoming oversold (up to a max of 6 candles) of available cash into the underlying security/token. I.e. the first buy is 10% of available cash and occurs in the first oversold candle, the second buy is 20% of available cash and occurs in the second oversold candle, etc. up to six consecutive oversold candles. Lastly, to ensure no conflicting orders and no leverage (buying more than what is affordable with the available cash in the fund), buy-the-dip orders take precedence over the trend-trading orders enumerated in the previous paragraph.


† Technically the strategy goes 99.5% in when it goes "all-in". This is to ensure no leverage is used given that there may be a commission of 0.5%.



3. Backtest Results

Backtest results demonstrate significant outperformance over buy-and-hold. The default parameters of the strategy/indicator have been set by the author to achieve maximum (or, close to maximum) outperformance on backtests executed on the BTCUSD (Bitcoin) chart. However, significant outperformance over buy-and-hold is still easily achievable using non-default parameters. Basically, as long as the parameters are set to adequately capture the full character of the market, significant outperformance on backtests is achievable and is quite easy. In fact, after some experimentation, it seems as if underperformance hardly achievable and requires deliberately setting the parameters illogically (e.g. setting one parameter of the slow indicator faster than the fast indicator). In the interest of providing a quality product to the user, suggestions and guidelines for parameter settings are provided in section (6). Finally, some metrics of the strategy's outperformance on the BTCUSD chart are listed below, both for the default (optimal) parameters as well as for a random sample of parameter settings that adhere to the guidelines set forth in section (6).

Using the default parameters, relative to buy-and-hold strategy, backtested from August 2011 to August 2020,
  • Total cumulative outperformance (total return of strategy minus total return of buy-n-hold): 13,000,000%.
  • Rolling 1-year outperformance: mean 318%, median 84%, 1st quartile 55%, 3rd quartile, 430%.
  • Rolling 1-month outperformance: mean 2.8% (annualized, 39%), median -2.1%, 1st quartile -7.7%, 3rd quartile 13.2%, 10th percentile -13.9%, 90th percentile 24.5%.


Using the default parameters, relative to buy-and-hold strategy, during specific periods,
  • Cumulative outperformance during the past year (August 2019-August 2020): 37%.
  • 12/17/2016 - 12/17/2017 (2017 bull market) absolute performance of 2563% vs buy-n-hold absolute performance of 2385%
  • 11/29/2012 - 11/29/2013 (2013 bull market) absolute performance of 14033% vs buy-n-hold absolute performance of 9247%


Using a random sample (n=20) of combinations of parameter settings that adhere to the guidelines outlined in section (6), relative to buy-and-hold strategy, backtested from August 2011 to August 2020,
  • Average total cumulative outperformance, from August 2011 to August 2020: 2,000,000%.
  • Median total cumulative outperformance, from August 2011 to August 2020: 1,000,000%.


snapshot



4. Limitations

This strategy is basically a DCA-swing trading strategy, and as such it is intended to be used on the 6-hr chart. Similar performance is expected on daily chart, 12-hr chart, and 4-hr chart, but performance is likely to be limited when used on charts of shorter time-frames. However, due to the flexibility afforded by the large quantity of parameters, as well as the tools included, it may be possible to tweak the indicator settings to get some outperformance on smaller time-frames. Admittedly, the author did not spend much time investigating this.

As is apparent in the backtests, this strategy has very limited absolute performance during large bear markets, such as Bitcoin's 2018 bear market. As described, it does outperform the underlying security by a large amount in backtests, but a large absolute return is unlikely during large and prolonged declines (unless, of course, your unit of account is the underlying token, in which case an outperformance of the underlying is, by definition, an absolute positive return).

This strategy is likely to underperform if used to trade ETFs of broad equity markets. This strategy may produce a small amount of outperformance when used to trade precious metals ETFs, given that the parameters are set optimally by the user.



5. Use

The default parameters have already been set for highly optimal backtest results on the chart of BTCUSD (Bitcoin / US Dollar BITSTAMP), (although, a different combination of parameter settings may yet produce better results). Still, there is a great number of combinations that can be explored, so the user is free to tweak the settings to meet his/her/their needs. Some display options are provided to give the user a visual aid while tweaking the parameters. These include a blue/red background display of the custom indicator, a calibration system, and options to display information about the backtest results. The background pattern represents the various levels of bullishness/bearishness as semi-transparent layers of blue and red, with blue corresponding with bullish and red corresponding with bearish.

The parameters that affect the indicator are the response times, the periods, and some EMA lengths. The parameters that affect the quantity of contracts (tokens/shares/bitcoins/etc) to be bought/sold are the transitionary buy/sell rates. There are also two sets of date parameters.

The response time and period parameters are direct inputs into the underlying math formula and are used to create the base-level indicators (fast, moderate, and slow). The response times control the speed of each of the three indicators (shorter is fast, longer is slower) and the period controls how much historical data is used in computation. Information about how these should be set are included in section (6). Another set of parameters control EMA look-back periods that serve to smooth the base-level indicators. Increasing these EMA lengths makes the overall indicator less sensitive to short-term price action, while reducing them does the opposite. The effect of these parameters are obvious when the background blue/red visualization is displayed. Another EMA length is an EMA for the entire indicator. Increasing this parameter reduces the responsiveness of the trading strategy (buy/sell orders) to quick/small changes of the overall level of the indicator, so as to avoid unnecessary buying and selling in times of relatively small and balanced price perturbations. Note, changing this parameter does not have an effect on the overall indicator itself, and thus will not affect the blue/red background representation.

The transitionary buy/sell rates control the portion of the available asset to be converted to the other. E.g. if the buy rate is set to 90%, then 90% of the available cash will be used to buy contracts/tokens/shares/bitcoins during transitions bullish transitions, e.g. if the available cash at the start of the bullish transition is $10,000 and the parameter is set to 90%, then $9,000 will be used to buy in the first candle during which the transition is bullish, then $900 will be used to buy in the second candle, then $90 in the third candle, etc.

There are two dates that can be set. The first is the date at which the strategy goes all in. This is included because the buy-and-hold strategy is the benchmark against which this strategy is compared, so setting this date to some time before the strategy starts to make trades will show, very clearly, the outperformance of the strategy, especially when the initial capital parameter in the Properties tab is equal to the price of one unit of the underlying security on the date that is set, e.g. all-in on Bitcoin on 8/20/2011 and set initial capital to the BTCUSD price on that date, which was $11.70. The second date is a date to control when the strategy can begin to place trades.

Finally (actually, firstly in the Inputs dialogue box), a set of checkbox inputs controls whether or not the backtest is on or off, and what is displayed. The display options are the blue/red (bull/bear) background layers †, a set of calibrators, a plot of the total strategy equity, a plot of the cash position of the strategy, a plot of the size of the position of the strategy in contracts/shares/units (labeled as BTC position), and a plot of the rolling 1-year performances of buy-and-hold and the strategy.

About the calibrators: The calibration system allows the user to quickly assess and calibrate how well the indicator... indicates. Quite simply, the system has two parts: one plot that is the cumulative sum of the product of the indicator level and the change in the underlying price, i.e. sum of [indicator level x (close - previous close)] ‡, over all candles. The second part is a similar plot that is reduced according to the quickness with which the indicator changes, i.e. sum of [indicator level x (close - prev close) / (1 + |indicator lvl - prev indicator lvl|)]. Maximizing the first plot at the expense of the second will cause the indicator to match the price action very well but therefore it will change very rapidly, from bullish to bearish, which is visualized by a background pattern that changes frequently from blue to red to blue. Ignoring the first plot and maximizing the second will also cause the indicator to more closely match the price action, but the transitions will be slower and less frequent, and will therefore focus on identifying the major trends of the market.


† The blue/red background has many layers and will make the chart lag as the user interacts with it.
‡ Bearish states are coded as negative quantities, so a bearish state x negative price action = positive number, and bullish state x positive price action = positive number.



6. Suggestions and Guidelines

As described in section (2.1), the indicator used in this strategy was designed to determine the state of the market--whether it is bullish or bearish--as well as the change in the state of the market--whether it is increasingly bullish or increasingly bearish. As such, the following suggestions are provided based on the principles of the indicator's design,

1. Response Time 1 should be less than (<) Response Time 2 which should be < Response Time 3
2. Fast Period < Moderate Period < Slow Period
3. In terms of the period of a full market cycle (e.g. ~ 4 years for BTC, ~ 5.5 years for equities, etc.), response times 1, 2, and 3 should be about 0.3% to 1%, 3% to 20%, and 20% to 50% of a full market cycle period, respectively. However, this is a loose guideline.
4. In terms of the period of a full market cycle, periods 1, 2, and 3 should all be about 25% to 75% of a full cycle period. Again, this is a loose guideline.
4. EMA 1 Length < EMA 2 Length < EMA 3 Length < EMA 4 Length
5. EMA Lengths 1, 2, 3, and 4 should be limited to about 1/4th the length of a full market cycle. Note, EMA lengths are measured in bars (candles), not in days. 1/4th of 1000 days is 250 days which is 250 x 4 = 1000 6-hr candles.

The following guidelines are provided based on results of over 100 backtests on the BTCUSD chart using randomized parameters †,

1. 9 days < Response Time 1 < 14 days
2. 5 days < EMA 1 Length < 100 days
3. 600 days < EMA 4 length < 1000 days
4. The ratio of the EMA range (EMA 4 len - EMA 1 len) to the sum of EMA lengths (EMA 1 len + EMA 2 len + ...) be greater than 0.4
5. The ratio of the sum of EMA 1 and EMA 2 lengths to the sum of EMA 3 and EMA 4 lengths be less than 0.3.

A suggestion from the author: Given that backtests show a high degree of outperformance using the guidelines enumerated above, a good trading strategy may be to not rely on any one particular combination of parameters. Rather, a random set of combinations of parameter settings that adhere to the guidelines above could be used to create multiple instances of the strategy in a TradingView chart, each of which varies by a small amount due to their unique parameter settings. The proportion of the entire set of strategy instances that agree about the current state of the market could indicate to the trader the level of confidence of the indicator, in aggregate.


† A sample dataset of backtest results using randomized parameters is available upon request; notably, all trials outperformed the intended market (Bitcoin).



7. General Remarks About the Indicator

Other than some exponential moving averages, no traditional technical indicators or technical analysis tools are employed in this strategy. No MACD, no RSI, no CMF, no Bollinger bands, parabolic SARs, Ichimoku clouds, hoosawatsits, XYZs, ABCs, whatarethese. No tea leaves can be found in this strategy, only mathematics. It is in the nature of the underlying math formula, from which the indicator is produced, to quickly identify trend changes.



8. Remarks About Expectations of Future Results and About Backtesting

8.1. In General
As it's been stated in many prospectuses and marketing literature, "past performance is no guarantee of future results." Backtest results are retrospective, and hindsight is 20/20. Therefore, no guarantee can, nor should, be expressed by me or anybody else who is selling a financial product (unless you have a money printer, like the Federal Reserve does).

8.2. Regarding This Strategy
No guarantee of future results using this strategy is expressed by the author, not now nor at any time in the future.

With that written, the author is free to express his own expectations and opinions based on his intimate knowledge of how the indicator works, and the author will take that liberty by writing the following: As described in section (7), this trading strategy does not include any traditional technical indicators or TA tools (other than smoothing EMAs). Instead, this strategy is based on a principle that does not change, it employs a complex indicator that is based on a math formula that does not change, and it places trades based on five simple rules that do not change. And, as described in section (2.1), the indicator is designed to capture the full character of the market, from a macro/global scope down to a micro/local scope. Additionally, as described in section (3), outperformance of the market for which this strategy was intended during backtesting does not depend on luckily setting the parameters "just right." In fact, all random combinations of parameter settings that followed the guidelines outperformed the intended market in backtests. Additionally, no parameters are included within the underlying math formula from which the indicator is produced; it is not as if the formula contains a "5" and future outperformance would depend on that "5" being a "6" instead. And, again as described, it is in the nature of the formula to quickly identify trend changes. Therefore, it is the opinion of the author that the outperformance of this strategy in backtesting is directly attributable to the fundamental nature of the math formula from which the indicator is produced. As such, it is also the opinion of the author that continued outperformance by using this strategy, applied to the crypto (Bitcoin) market, is likely, given that the parameter settings are set reasonably and in accordance with the guidelines. The author does not, however, expect future outperformance of this strategy to match or exceed the outperformance observed in backtests using the default parameters, i.e. it probably won't outperform by anything close to 13,000,000% during the next 9 years.

Additionally, based on the rolling 1-month outperformance data listed in section (3), expectations of short-term outperformance should be kept low; the median 1-month outperformance was -2%, so it's basically a 50/50 chance that any significant outperformance is seen in any given month. The true strength of this strategy is to be out of the market during large, sharp declines and capitalizing on the opportunities presented at the bottom of those declines by buying the dip. Given that such price action does not happen every month, outperformance in the initial months of use is approximately as likely as underperformance.



9. Access

Those who are interested in using this strategy may send a personal message to inquire about how to gain access. Those who are interested in acquiring the sample dataset of backtest results may send a personal message to request a copy of the data.
Informacje o Wersji
Bug fixes involving some conditionals. Added an "end date" setting.
Informacje o Wersji
Front image change. Negligible.
Informacje o Wersji
Front image change, again.
Bitcoin (Cryptocurrency)buythedipmathematicalOscillatorsswingtradingTrend Analysis

Skrypt tylko na zaproszenie

Dostęp do tego skryptu mają tylko użytkownicy upoważnieni przez autora i zazwyczaj wiąże się z opłatą. Możesz dodać go do ulubionych, ale będziesz mógł z niego korzystać dopiero po uzyskaniu zgody jego autora. Skontaktuj się z anon2414691 po więcej informacji lub postępuj zgodnie z instrukcjami autora poniżej.

TradingView nie sugeruje płacenia za skrypt i korzystania z niego, jeśli nie ufasz w 100% jego autorowi i nie rozumiesz, jak działa skrypt. W wielu przypadkach możesz znaleźć dobrą alternatywę open-source za darmo w naszych Skryptach Społeczności.

Instrukcje autora

Chcesz użyć tego skryptu na wykresie?

Ostrzeżenie: przeczytaj to zanim poprosisz o dostęp.

Wyłączenie odpowiedzialności