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

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?