OPEN-SOURCE SCRIPT

Buy The Deep Final Version V3

Buy The Deep Final Version V3

This script implements a buy-the-dip strategy based on market volatility, featuring multi-level additional buy logic and performance visualization tools for traders.

Key Features
  1. Dynamic Position Sizing:Dynamically calculates position size based on the trader's initial capital, current profit, and leverage settings.Offers options to reinvest profits or maintain fixed position sizes.
  2. Volatility-Based Entry:Identifies buy opportunities based on a calculated volatility percentage (val).
  3. Automated Take Profit and Stop Loss:Automatically sets take profit (tp) and stop-loss (tp22) levels using predefined percentages to ensure effective risk management.
  4. SMA-Based Conditions:Uses a Simple Moving Average (SMA) to determine whether to enter long positions.
  5. Support for Additional Buy Levels:Supports dollar-cost averaging (DCA) with additional buy levels (so1, so2, etc.).
  6. Leverage and Commission Customization:Allows users to set desired leverage and trading fees, which are incorporated into calculations for precise execution.
  7. Performance Tracking:Displays the following key metrics:[]Total profit and percentage []Monthly and annual profit percentages []Maximum drawdown (MDD) []Win rate Includes a performance table and data window for real-time insights.
  8. Time-Limited Testing:Enables users to test the strategy over specific time periods for refinement and validation.


How It Works:
  • []Entry Conditions: Identifies opportunities when the price crosses above the SMA or meets specific volatility thresholds. []Position Sizing: Dynamically calculates optimal position sizes using leverage and capital allocation.
  • Exit Points: Automated take profit and stop-loss orders minimize manual intervention.


Input Descriptions

This strategy offers customizable input parameters to accommodate various trading needs. Each input is described below:

  1. []Initial Settings
    • []Profit Reinvest (reinvest):Options: True or FalseDetermines whether to reinvest profits to increase the size of subsequent trades.
    • Long Buy % (longper):Default: 6Sets the percentage of initial capital allocated for the first long position.
    • Leverage (lev):Default: 3Sets the leverage multiplier for trades. For example, 3 means 3x leverage is used.
    • Fee % (commission_value):Default: 0.044Input the trading fee as a percentage, which is factored into profit calculations.
    • Decimal Places (num):Default: 2Determines the number of decimal places considered in calculations.
    • Table Font Size (texts):Default: NormalSets the font size for the performance table. Options include Tiny, Small, Normal, and Large.


  1. []Volatility and Additional Buy Settings
    • []Volatility % (val):Default: -1.5Specifies the volatility percentage used to determine entry points.
    • Additional Buy % (so):Default: -3Defines the percentage drop at which additional buy orders are executed.
    • Take Profit % (tp):Default: 0.5Specifies the percentage increase at which take profit orders are executed.
    • Candle Count (sl):Default: 1Sets the number of candles to hold a position before closing it.
    • Take Profit Stop-Loss % (tp22):Default: 0.1Defines the stop-loss threshold as a percentage below the average entry price.
    • SMA Length (len):Default: 48Determines the period for calculating the Simple Moving Average (SMA).


  1. []Position Multipliers
    • []Position Multiplier Longline 4 (long2_qty):Default: 1Sets the size of the first additional buy position.
    • Position Multiplier Longline 5 (long3_qty):Default: 2Sets the size of the second additional buy position.
    • Position Multiplier Longline 4 (long4_qty):Default: 4Sets the size of the third additional buy position.
    • Position Multiplier Longline 5 (long5_qty):Default: 8Sets the size of the fourth additional buy position.
buythedipbybitcopytradingSimple Moving Average (SMA)smaVolatilityvotality

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

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

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

免責事項