INVITE-ONLY SCRIPT

FreedX Backtest Plus

Updated
█ Our new FreedX Backtest PLUS template enhances TradingView backtesting with smart features like Mean Reversion, Flexible Volatility, Liquidation Filter, and Better Trend Filtering, making strategies more effective. It lets users set up automated alerts easily. This guide explains how to make the most of these improved features.

The Trading Date Settings feature in our TradingView script allows you to refine their backtesting parameters by specifying trading dates and hours. This feature enhances the accuracy of the backtest by aligning it with specific time frames and days, ensuring that the strategy is tested under relevant market conditions.

snapshot

Features:

⚙️ Enable Trading Between Specific Dates:
  🎯 Purpose:
    → Allows you to limit the backtesting of their strategy to a specific date range.
  💡 How to Use:
    → Input the Start Date and End Date for the backtest period.
    → The script will execute the strategy only within this specified date range.

⚙️ Enable Trading Between Specific Hours:
  🎯 Purpose:
    → Allows you to limit the backtesting of their strategy to a specific hour range.
  💡 How to Use:
    → Input the start and end hour for in Trading Session section.
    → The script will execute the strategy only within this specified hour range.

⚙️ Enable Trading on Specified Days of the Week:
  🎯 Purpose:
    → Gives you the option to conduct backtesting on selected days of the week, tailoring the strategy to particular market behaviours that may occur on these days.
  💡 How to Use:
    → Select the days of the week for the backtest.
    → The script will activate the trading strategy only on these chosen days.

█ BUY/SELL TRIGGER SETTINGS

The Buy/Sell Trigger Settings feature is designed to provide users with flexibility in defining the conditions for 'LONG' and 'SHORT' signals based on various indicator types. This customization is crucial for tailoring strategies to different trading styles and market conditions.

Features:

⚙️ Single-Line Plotted Indicators:
  🎯 Purpose:
    → Enables you to select a single-line plotted indicator as a source for backtesting. You can define specific levels to trigger 'LONG' or 'SHORT' signals.
  💡 How to Use:
    → Choose a Single-Line Plotted indicator as the source.
    → Set the top and bottom levels for the indicator.
    → The script triggers 'LONG' signals at the bottom level and 'SHORT' signals at the top level.

snapshot

⚙️ Two-Line Plotted Indicators:
  🎯 Purpose:
    → Allows backtesting with two-line cross plot sources. Signals are generated based on the crossover of these lines.
  💡 How to Use:
    → Select two lines as 'Source 1' and 'Source 2' for the indicator.
    → The script triggers a 'LONG' signal when 'Source 1' crosses above 'Source 2'.
    → Conversely, a 'SHORT' signal is triggered when 'Source 2' crosses above 'Source 1'.

snapshot

⚙️ Custom Signals:
  🎯 Purpose:
    → This setting enables users to define their own criteria for LONG, SHORT, and CLOSE signals based on custom indicator outputs.
  💡 How to Use:
    → Select the custom source for your signals.
    → Define the output values that correspond to each signal type (e.g., “1” for 'LONG', “-1” for SHORT, and “0” for CLOSE).
    → The script will trigger signals according to these custom-defined values.

█ TP/SL SETTINGS

The TP/SL (Take Profit/Stop Loss) Settings feature is designed to give users control over their profit securing and risk mitigation strategies. This feature allows for setting custom TP and SL levels, which can be critical in managing trades effectively.

Features:

Custom TP/SL Levels for Long/Short Signals:
  🎯 Purpose:
    → Enables users to set specific percentage levels for Take Profit and Stop Loss on long and short signals.
  💡 How to Use:
    → In the TP/SL Settings, input the desired percentage for Take Profit (TP) and Stop Loss (SL).
    → For example, to secure a profit at a 10% price increase on LONG signals, set the “Long TP Percentage” to “10”.

snapshot

STRATEGY SETTINGS

Strategy Settings provide a range of options to customize the trading strategy. These settings include leverage, position direction changes, and more, allowing users to tailor their strategy to their risk tolerance and market view.

snapshot

Features:

⚙️ Enable Reverse Position:
  🎯 Purpose:
    → Automatically closes a current position and opens a new one in the opposite direction upon detecting a signal for a market trend change.
  🎯 Example:
    → If a LONG signal is received while in a SHORT position, the script will close the SHORT position and open a LONG position.
  💡 How to Use:
    → Activate this feature in the Strategy Settings.

⚙️ Enable Spot Mode:
  🎯 Purpose:
    → Disables short orders, using short signals only for closing long positions.
  💡 How to Use:
    → Select the 'Spot Mode' option in the Strategy Settings.

⚙️ Enable Invert Signals:
  🎯 Purpose:
    → Inverts all indicator signals, changing LONG signals to SHORT and vice versa.
  💡 How to Use:
    → Opt for the 'Invert Signals' feature in the Strategy Settings.

⚙️ Enable Trailing Stop:
  🎯 Purpose:
    → Triggers a trailing stop order on the exchange instead of a standard stop market order.
  ☢️ Caution:
    → The backtesting of this feature on TradingView may not accurately reflect actual strategy performance due to discrepancies between TradingView and exchange mechanisms.
  💡 How to Use:
    → Select 'Trailing Stop' in the Strategy Settings.

⚙️ Enable Realistic TP & SL:
  🎯 Purpose:
    → Goal is protect the user from unrealistic stop loss and take profit prices in live exchange trading conditions.
    → That feature continuously checks the take profit, stop loss and move stop loss prices to prevent unrealistic values. It changes their values according to (minimum realistic percent %)
  💡 How to Use:
    → Select 'Enable Realistic TP & SL' in the Strategy Settings. Write min allowed percents.

LIMITER SETTINGS

Limiter Settings provide a range of options to customize the trading strategy. These settings include drawdown limits,contract limit, tradable ratio, for allowing users to tailor their strategy to their risk tolerance and market view.

snapshot

⚙️ Leverage:
  🎯 Purpose:
    → Allows users to apply leverage to their trades.
  ☢️ Caution:
    → High leverage can significantly increase the risk of liquidation.
    → High leverage and a high stop-loss price may override your fixed stoploss percentage, adjusting the stop-loss to the liquidation price.
  💡 How to Use:
    → Set the desired leverage ratio in the Strategy Settings.

⚙️ Drawdown Limit:
  🎯 Purpose:
    → Sets a maximum drawdown limit, automatically halting the strategy if this limit is reached, thereby controlling risk.
  💡 How to Use:
    → Input the maximum drawdown limit (default: 100, min: 0, max: 100).

⚙️ Contract Limit:
  🎯 Purpose:
    → Sets a maximum contract limit, beyond which the compound effect cannot be used. This is important to prevent market manipulation through large-volume orders.
  💡 How to Use:
    → Input the maximum contract limit (min: 0).

⚙️ Tradable Ratio:
  🎯 Purpose:
    → Sets a tradable ratio, it uses that ratio calculating entry cost for position. Main purpose is cash-out and cash-in according to balance change.
  💡 How to Use:
    → Input the tradable ratio percent (default: 98, min: 0.1, max: 100).

CASH-OUT SETTINGS

Cash-Out Settings offer a money-saving mechanism that prevents entering positions with the entire balance due to cashed-out funds. It functions with a webhook alerts, but the 'Override Allocation %' option must be enabled.

snapshot

⚙️ Cash-out Threshold %:
  🎯 Purpose:
    → It is cash-out mechanism, it saves money with a target threshold.
  💡 How to Use:
    → Input the threshold (min: 0).

⚙️ Cash-out Per Profitable Trades %:
  🎯 Purpose:
    → It is cash-out mechanism, it saves money from every trade with a percent like commission.
  💡 How to Use:
    → Input save percent% (min: 0).

ADAPTIVE VOLATILITY STRATEGY SETTINGS

Advanced Strategy Settings offer sophisticated methods for managing Stop Loss (SL) and Take Profit (TP) using the Average True Range (ATR). These settings are ideal for traders who want to incorporate volatility into their exit strategies.

snapshot

Features:

⚙️ Enable ATR Stop Loss:
  🎯 Purpose:
    → Automatically sets the Stop Loss price using the Average True Range at the time of entry.
  💡 How to Use:
    → Activate 'ATR Stop Loss' to have the SL price calculated based on the current ATR.
  ⛓ Enable ATR Trailing Stop:
    → Dynamically updates the Stop Loss price with each new bar, according to the Average True Range.
    → Activate 'ATR Trailing Stop'.
    → Set the ATR Period to define the number of bars for ATR calculation.
    → Adjust the ATR SL Multiplier to determine the stop loss distance.
    → Modify the ATR TP Multiplier for setting the take profit distance.

⚙️ Enable ATR Take Profit:
  🎯 Purpose:
    → Sets the Take Profit price based on the Average True Range at the time of entry.
  💡 How to Use:
    → Choose 'ATR Take Profit' for TP price determination using ATR.

⚙️ Enable ATR Limit Entry:
  🎯 Purpose:
    → Trade can not open in candle close price. Price should hit target price that based on average true range value.
  💡 How to Use:
    → Choose 'ATR Limit Entry' for entry price determination using ATR.
  ⛓ Enable ATR Limit Entry Trailing Price:
    → Dynamically updates the entry price with each new bar, according to the Average True Range.
    → Activate 'ATR Limit Entry Trailing Price'.
    → Set the ATR Period to define the number of bars for ATR calculation.
    → Adjust the ATR SL Multiplier to determine the stop loss distance.
    → Modify the ATR TP Multiplier for setting the take profit distance.

TREND FILTERING SETTINGS

Trend Filtering Settings are designed to align trading strategies with the prevailing market trend, enhancing the precision of trade entries and exits. These settings utilize moving averages for trend analysis and decision-making.

snapshot

Features:

⚙️ Enable Moving Average Filtering:
  🎯 Purpose:
    → Limits trades based on moving average trends, blocking short trades in an uptrend and vice versa.
  💡 How to Use:
    → Enable 'Trend Filtering'.
    → Set Fast and Slow MA Lengths for trend analysis.
    → Select the Timeframe for moving averages.
    → Choose the Moving Average Type for trend filtering.
  🎯 Note:
    → Be cautious with timeframe selections; lower timeframes than the base may cause inconsistencies.

  ⛓ Exit on Trend Reversal:
    → Automatically closes a position when a market trend reversal is detected.
    → Turn on 'Exit on Trend Reversal' in the settings.

  ⛓ Ignore Counter Signals:
    → Ignores counter signals during trending market way.
    → If the trend way is long. All short signals will ignore and vice versa.

  ⛓ Enable Drawing On Chart:
    → Visually represents the trend filter directly on the chart for easy reference.
    → Activate 'Drawing On Chart' to see the trend filter overlaid on the trading chart.

⚙️ Enable Adx Filtering:
  🎯 Purpose:
    → Limits trades based on adx value, blocking trades if trend strength is not enough or vice versa for invert mode.
  💡 How to Use:
    → Enable 'Adx Filtering'.
    → Set Smoothing and Lengths for adx trend analysis.
    → Select level barrier for trend strength.

⚙️ Enable Custom Filtering:
  🎯 Purpose:
    → Limits trades based on custom sources, blocking trades according to custom trades.
  💡 How to Use:
    → Enable 'Custom Filtering'.
    → Select fast source.
    → Select slow source.
    → [Optional] Enable lag mode.

MEAN REVERSION FILTERING SETTINGS

Mean Reversion Filtering Settings are designed to align trading strategies during accumulation market conditions. They set a distance from a line to permit trading. The purpose is to ensure that when the price strays too far from the mean line, it should revert back. In accumulation markets, price movements are generally horizontal. In such situations, mean reversion will operate like a grid, enabling profitable trades with low drawdown. However, when the market structure begins to trend, mean reversion filters may not be as profitable as in accumulation markets. For instance, let's say the price is rising and we are shorting the market until it reaches the mean price line. As the price goes up and the mean also rises, we will end up closing the position at a higher price, rendering the mean reversion system non-profitable. Therefore, consider this filter wisely; greater distances might work better in trending markets.

snapshot

Features:

⚙️ Enable Kairi Filter:
  🎯 Purpose:
    → Blocks trades based on distance percent between price and moving average.
  💡 How to Use:
    → Enable 'Kairi Filter'.
    → Set Length and Distance Percent.

  ⛓ Enable Trend Drawing On Chart:
    → Visually represents the trend filter directly on the chart for easy reference.
    → Enable 'Drawing On Chart' to see the allowed regions overlaid on the trading chart with arrows.

⚙️ Enable VWAP Filter:
  🎯 Purpose:
    → Blocks trades based on distance percent between price and volume weighted average price.
  💡 How to Use:
    → Enable 'VWAP Filter'.
    → Set Timeframe as minutes and distance as percent.

  ⛓ Exit on Crossing with VWAP:
    → Automatically closes a position when the closing price of a candle crosses the VWAP.
    → Choose "Enable", 'Exit on Crossing with VWAP' in the settings.

  ⛓ Enable Drawing On Chart:
    → Visually represents the trend filter directly on the chart for easy reference.
    → Enable 'Drawing On Chart' to see the allowed regions overlaid on the trading chart with arrows.

LIQUIDATION FILTER SETTINGS

Liquidation filter compares the volume data of futures and spot markets.
Large differences in volume indicate unexpected market conditions, such as massive trading activities, which may signal liquidations.

snapshot

Features:

⚙️ Enable Liquidation Filter:
  🎯 Purpose:
    → Blocks trades based on extra ordinary volume differences in spot and futures market.
  💡 How to Use:
    → Enable 'Liquidation Filter'.
    → Set behavior to react during that market conditions.
→ Set base amount to filter volume. This amount changes according to timeframe, you should find right amounts.
→ Liquidation candle count means, it is sum of liquidated candle count in last 20 bars.If you set 0, it means feature is disabled.
→ Detection, try to select the spot and perpetual symbols automatically, symbol names varies, it do not support all symbols, you should choose manually in that situation.

AUTOMATED ALERT SETTINGS

Automated Alert Settings are designed to integrate your TradingView script with webhook alerts. These settings allow for enhanced strategy execution and management.

Features:

Enable Webhook Alerts:
  🎯 Purpose:
    → Trigger BUY, SELL, CHANGE_DIRECTION or MOVE_STOP_LOSS .
  💡 How to Use:
    → Enable 'Webhook Alerts' in the settings.
    → Enter your Strategy Key.
    → Optionally, activate 'Override Allocation Percentage' to bypass the preset allocation percentage.
  ☢️ Caution:
    → Overriding the allocation percentage may result in trade entry errors due to misalignment between entry cost and available balance.

Enable Custom Alerts:
  🎯 Purpose:
    → User can produce unique messages for different purposes.
  💡 How to Use:
    → Enable 'Custom Alerts' in the settings.
    → Enter your message format type.

snapshot

DEBUGGING SETTINGS

Debugging Settings are crucial for users who want to analyze and optimize their strategies. These settings provide tools for visualizing alerts on charts and accessing detailed data outputs.

snapshot

Features:

⚙️ Enable Alert Plotting:
  🎯 Purpose:
    → Allows users to visualize trading alerts directly on the chart, aiding in strategy analysis and refinement.
  💡 How to Use:
    → Activate 'Alert Plotting' to draw alerts on the chart.
  ☢️ Caution:
    → It is recommended to disable this feature when creating actual trading alerts, as it can cause latency in signal processing.

⚙️ Enable Debugger Mode:
  🎯 Purpose:
    → Facilitates strategy debugging by providing detailed data output in the TradingView Data Window.
  💡 How to Use:
    → Turn on 'Debugger Mode' to access real-time data and metrics relevant to your strategy.

⚙️ Enable Table:
  🎯 Purpose:
    → Facilitates strategy debugging by providing detailed data output in the TradingView Table on chart.
  💡 How to Use:
    → Turn on 'Table' to access last closed candle data and metrics relevant to your strategy.

ADDITIONAL SETTINGS

snapshot

⚙️ Enable Bar Magnifier
⚙️ Enable Using standard OHLC
Release Notes
🛠 Def Settings:
    → Default strategy settings changed. Infos added. Take Profit (TP) & Stop Loss (SL) precisions increased.

🛠 Alarm:
    → Alarm messages enhanced. If the start date is equal to the last bar time, the alarm produces a validate test signal.

🛠 Custom Trend Filter:
    → Filter enhanced to display imported plots.
Release Notes
🛠 Trigger Signals:
    → Single Line Trigger Signals -> Invert signals mode added. Tooltips updated.
    → Cross Trigger Signals -> Invert crossing mode added. Tooltips updated.

🛠 Backtest Calculation:
    → All positions closed after reaching the last backtest date to prevent missing unrealized profits.
    → Custom filter calculation and import enhancements.
    → Updated debug data window.
    → Atr max stop percentage now has a limit variable.
Release Notes
snapshot

🛠 Signal Settings
    → Signal Methods simplified for better experience.

🛠 Strategy Settings
    → Menu enhanced.
    → Position Sides added.
    → Limit Entry Orders added for maker fee entries.
    → Limit Entry Plot added for volatility entries.
    → Limit Exit Orders added for maker fee entries.

🛠 TP/SL/CLOSE Settings
    → Fixed TP/SL booleans added.
    → Custom Stoploss Plot added.
    → Crossing Close added.

🛠 Alarms:
    → Live mode has been added for alarms. Signals are calculated in real-time with data updates for fast alarms.
    → In live mode, users can choose how many seconds should be calculated for the alarm before the candle closes.

🛠 Trailing Stop
    → Trailing stop control warnings have been added. Users can disable warnings in the settings.

🛠 UI
    → Tooltips updated.
    → Errors and potential issues are reported in a table to protect users from mistakes.
    → Code efficiency has been increased with profiler mode.
Release Notes
🛠 TP/SL/CLOSE Settings
    → TP/SL Settings enhanced.
    → Risk-Reward TP Targets added.
    → Move Stop To Break Even feature added.
    → Crossing Value Close added.

🛠 Interval Filter:
    → Interval Value Filter added.
    → Interval Plot Filter added.

🛠 Position Sizing:
    → Cash-out features updated as position sizing.
Release Notes
🛠 TP/SL settings:
    → Custom take profit added.

🛠 Position Sizing:
    → Cash-out feature changed to dynamic position sizing for adaptive behavior.

🛠 Liq filter removed:
    → Liquidation filter removed to reduce script slowdown. It can be imported with coding.

🛠 Atr entry removed:
    → ATR limit entry can now be used with limit order plots and has been removed from atr features.

🛠 Interval Filter:
    → Added multiple options and sides for plot values in filtering conditions.

🛠 Limit Orders:
    → Limit order behavior enhanced with stop-limit; breakout strategies are now backtestable.

🛠 UI:
    → Overlay set to false. Processed signals are now visible in the indicator area.
backtestbacktestingBESTCandlestick analysiseducationalsignalstrategytemplatetesttestingTrend Analysis

Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact freedx for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases, you can find a good open-source alternative for free in our Community Scripts.

Author's instructions

Get instant access and start automating your indicator & strategy signals: https://freedx.ai

Want to use this script on a chart?

Warning: please read before requesting access.

Automate your backtested strategies with our trading automation software. Visit us at freedx.ai
Also on:

Disclaimer