OPEN-SOURCE SCRIPT

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.
automatedtradingBitcoin (Cryptocurrency)BTCBTCUSDETHEthereum (Cryptocurrency)ETHUSDTrend Analysistrendfollowing

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?


또한 다음에서도:

면책사항