carefulCamel61097

Trend Following based on Trend Confidence

This is a Trend Following strategy based on the Trend Confidence indicator.
The goal of this strategy is to be a simple Trend Following strategy, but also to be as precise as possible when it comes to the question 'how confident are we that a linear trend is ongoing?'. For this we calculate the 'confidence' of a linear trend in the past number of closing prices. The idea of this strategy is that past a certain confidence, the ongoing linear trend is more likely to continue than not.

Trend Confidence:
The Trend Confidence shows us how strong of a linear trend the price has made in the past number (given by Length parameter) of closing prices. The steepness of the price change makes the Trend Confidence more extreme (more positive for an uptrend or more negative for a downtrend), and the deviation from a straight line makes the Trend Confidence less extreme (brings the confidence closer to 0). This way we can filter out signals by wild/sudden price moves that don't follow a clear linear trend.
Math behind the Trend Confidence:
A linear fit is made on the past number of closing prices, using Ordinary Linear Regression. We have the steepness of the linear fit: b in y=a+bx. And we have the standard deviation of the distances from the closing prices to the linear fit: sd. The Trend Confidence is the ratio b/sd.

Entries and Exits:
For entry and exit points we look at how extreme the Trend Confidence is. The strategy is based on the assumption that past a certain confidence level, the ongoing linear trend is more likely to continue than not.
So when the Trend Confidence passes above the 'Long entry" threshold, we go Long. After that when the Trend Confidence passes under the 'Long exit' threshold, we exit. The Long entry should be a positive value so that we go Long once a linear uptrend with enough confidence has been detected.
When the Trend Confidence passes below the 'Short entry' threshold, we go Short. After that when the Trend Confidence passes above the 'Short exit' threshold, we exit. The Short entry should be a negative value so that we go Short once a linear downtrend with enough confidence has been detected.

Default Parameters:
  • The strategy is intended for BTC-USD market, 4 hour timeframe. The strategy also works on ETH-USD with similar parameters.
  • The Length is arbitrarily set at 30, this means we look at the past 30 closing prices to determine a linear trend. Note that changing the length will change the range of Trend Confidence values encountered.
  • The default entry and exit thresholds for Longs and Shorts do not mirror each other. This is because the BTC-USD market goes up more heavily and more often than it goes down. So the ideal parameters for Longs and Shorts are not the same.
  • The positive results of the strategy remain when the parameters are slightly changed (robustness check).
  • The strategy uses 100% equity per trade, but has a 10% stop loss so that a maximum of 10% is risked per trade.
  • Commission is set at 0.1% as is the highest commission for most crypto exchanges.
  • Slippage is set at 5 ticks, source for this is theblock.co.

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?