OPEN-SOURCE SCRIPT

Trend Deviation strategy - BTC [IkkeOmar]

Intro:
This is an example if anyone needs a push to get started with making strategies in pine script. This is an example on BTC, obviously it isn't a good strategy, and I wouldn't share my own good strategies because of alpha decay.

This strategy integrates several technical indicators to determine market trends and potential trade setups. These indicators include:

  • Directional Movement Index (DMI)
  • Bollinger Bands (BB)
  • Schaff Trend Cycle (STC)
  • Moving Average Convergence Divergence (MACD)
  • Momentum Indicator
  • Aroon Indicator
  • Supertrend Indicator
  • Relative Strength Index (RSI)
  • Exponential Moving Average (EMA)
  • Volume Weighted Average Price (VWAP)


It's crucial for you guys to understand the strengths and weaknesses of each indicator and identify synergies between them to improve the strategy's effectiveness.


Indicator Settings:

DMI (Directional Movement Index):
Length: This parameter determines the number of bars used in calculating the DMI. A higher length may provide smoother results but might lag behind the actual price action.


Bollinger Bands:

  • Length: This parameter specifies the number of bars used to calculate the moving average for the Bollinger Bands. A longer length results in a smoother average but might lag behind the price action.
  • Multiplier: The multiplier determines the width of the Bollinger Bands. It scales the standard deviation of the price data. A higher multiplier leads to wider bands, indicating increased volatility, while a lower multiplier results in narrower bands, suggesting decreased volatility.




Schaff Trend Cycle (STC):

  • Length: This parameter defines the length of the STC calculation. A longer length may result in smoother but slower-moving signals.
  • Fast Length: Specifies the length of the fast moving average component in the STC calculation.
  • Slow Length: Specifies the length of the slow moving average component in the STC calculation.




MACD (Moving Average Convergence Divergence):

  • Fast Length: Determines the number of bars used to calculate the fast EMA (Exponential Moving Average) in the MACD.
  • Slow Length: Specifies the number of bars used to calculate the slow EMA in the MACD.
  • Signal Length: Defines the number of bars used to calculate the signal line, which is typically an EMA of the MACD line.


Momentum Indicator:

Length: This parameter sets the number of bars over which momentum is calculated. A longer length may provide smoother momentum readings but might lag behind significant price changes.



Aroon Indicator:

Length: Specifies the number of bars over which the Aroon indicator calculates its values. A longer length may result in smoother Aroon readings but might lag behind significant market movements.


Supertrend Indicator:

  • Trendline Length: Determines the length of the period used in the Supertrend calculation. A longer length results in a smoother trendline but might lag behind recent price changes.
  • Trendline Factor: Specifies the multiplier used in calculating the trendline. It affects the sensitivity of the indicator to price changes.


RSI (Relative Strength Index):

Length: This parameter sets the number of bars over which RSI calculates its values. A longer length may result in smoother RSI readings but might lag behind significant price changes.



EMA (Exponential Moving Average):

  • Fast EMA: Specifies the number of bars used to calculate the fast EMA. A shorter period results in a more responsive EMA to recent price changes.
  • Slow EMA: Determines the number of bars used to calculate the slow EMA. A longer period results in a smoother EMA but might lag behind recent price changes.


VWAP (Volume Weighted Average Price):

Default settings are typically used for VWAP calculations, which consider the volume traded at each price level over a specific period. This indicator provides insights into the average price weighted by trading volume.




backtest range and rules:

  1. You can specify the start date for backtesting purposes.

  2. You can can select the desired trade direction: Long, Short, or Both.


Entry and Exit Conditions:

LONG:
  1. DMI Cross Up: The Directional Movement Index (DMI) indicates a bullish trend when the positive directional movement (+DI) crosses above the negative directional movement (-DI).
  2. Bollinger Bands (BB): The price is below the upper Bollinger Band, indicating a potential reversal from the upper band.
  3. Momentum Indicator: Momentum is positive, suggesting increasing buying pressure.
  4. MACD (Moving Average Convergence Divergence): The MACD line is above the signal line, indicating bullish momentum.
  5. Supertrend Indicator: The Supertrend indicator signals an uptrend.
  6. Schaff Trend Cycle (STC): The STC indicates a bullish trend.
  7. Aroon Indicator: The Aroon indicator signals a bullish trend or crossover.


When all these conditions are met simultaneously, the strategy considers it a favorable opportunity to enter a long trade.

SHORT:
  1. DMI Cross Down: The Directional Movement Index (DMI) indicates a bearish trend when the negative directional movement (-DI) crosses above the positive directional movement (+DI).
  2. Bollinger Bands (BB): The price is above the lower Bollinger Band, suggesting a potential reversal from the lower band.
  3. Momentum Indicator: Momentum is negative, indicating increasing selling pressure.
  4. MACD (Moving Average Convergence Divergence): The MACD line is below the signal line, signaling bearish momentum.
  5. Supertrend Indicator: The Supertrend indicator signals a downtrend.
  6. Schaff Trend Cycle (STC): The STC indicates a bearish trend.
  7. Aroon Indicator: The Aroon indicator signals a bearish trend or crossover.


When all these conditions align, the strategy considers it an opportune moment to enter a short trade.



Disclaimer:
THIS ISN'T AN OPTIMAL STRATEGY AT ALL! It was just an old project from when I started learning pine script!
The backtest doesn't promise the same results in the future, always do both in-sample and out-of-sample testing when backtesting a strategy. And make sure you forward test it as well before implementing it!

Furthermore this strategy uses both trend and mean-reversion systems, that is usually a no-go if you want to build robust trend systems.

Don't hesitate to comment if you have any questions or if you have some good notes for a beginner.




AroonboolingerbandBTCUSDDMIeducationalmacdcrossoverOscillatorsPine utilitiesrsi-emaSchaff Trend Cycle (STC)STCsupertrend

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?


Join my community where i share signals and my secret algos:

Telegram:
t.me/ikkeomarfree

I can also pass funded accounts for you!
$50,000 accounts

Just dm my Telegram @IkkeOmar
Auch am:

Haftungsausschluss