INVITE-ONLY SCRIPT

- Trading Bot – TopBot Anomaly Robot Strategy -

Updated
- Introduction -

This strategy is based on a search for abnormal market price movements relative to a time-shifted main moving average. Different variations of the main moving average are created and shifted proportionally rather than linearly, giving the strategy greater reactivity and serving as position entry points. What's more ? This strategy stands out with a major innovation, allowing position exits to be set on variations in the moving average (and not on the moving average itself, like all strategies that close positions on return to the moving average), which greatly improves actual results.


- Detailed operation of the strategy -
  • It defines a function that calculates various moving averages (depending on the type of moving average defined by the user) and the chosen length. The function takes into account different types of moving averages: SMA, PCMA, EMA, WMA, DEMA, ZLEMA and HMA, and is offset in time so that it can be an entry or exit condition in real time (otherwise you'd have to wait for the next candle for the moving average to be calculated).

  • It calculates shifted variants (semi-parallel) as a percentage of this main moving average, high and low, to define position entry points (depending on user settings, up to 10 shifted levels for ten position entries for each direction). By calculating shifts as percentages rather than fixed values, the resulting deviations are not parallel to the main moving average, but can be used to detect sudden price contractions. By adjusting these deviations proportionally, we can observe variations relative to the main moving average more clearly, enabling us to detect dynamic support and resistance zones that adapt to market fluctuations. The fact that they are not strictly parallel avoids too rigid an interpretation and gives a more nuanced reading of trends, capturing small divergences that could indicate more subtle changes in market dynamics.

  • The most distinctive feature of this strategy concerns position exits: the script calculates two new moving averages shifted in proportion to the main moving average (adjustable) to define position exit price levels.

  • The strategy enters position when one of the deviations from the position entry moving average is crossed, and exits position when the deviation from the position exit moving average is crossed.

  • Position entry can be single or up to ten entry levels per direction to smooth trades. Differentiated settings are available for Longs and Shorts.


snapshot

In this type of strategy, the return to the moving average is generally used as the position exit point, but this strategy incorporates a unique feature: the position exit can be made on a deviation from the moving average, adjustable and differentiated for Long and Short positions.
This is a major change compared to other strategies using a moving-average position exit, since the result is thatchanging the position exit point considerably improves the strategy's results.

Backtest with a classic exit back to the moving average :
snapshot

Backtest with an exit back on an (adjustable) derivative of the moving average :
snapshot


- “Ready to use” and user-adjustable parameters -

The strategy interface has been optimized for easy creation of trading robots, with all settings underlying the calculations and numerous options for optimization. Here are the contents of the strategy parameters interface:

snapshot

In addition, important information about strategy settings and results is displayed directly on the chart. The percentage profit displayed may differ slightly from that of the backtest, as it includes potential profits from open trades (strategy.openprofit) in its calculation.


- Conditions, options and settings for graph and backtest presentation -

Here are the conditions and settings for the graph presented on the screen:
  • The strategy is set for 10 possible LONG and SHORT entries

  • 10% of capital in x2 leverage is invested at each position entry (i.e. 20% of capital under backtest conditions)

  • The backtest runs for 14 months: from 08/17/2023 to 08/19/2024

  • It is carried out on PENDLEUSDT.P on BitGet Swap in 4H

  • LONGS strategy settings: 0.18 - 0.19 - 0.2 - 0.21 - 0.22 - 0.23 - 0.24 - 0.25 - 0.26 - 0.275 - LONGS output deviation: 0.03 (3%)

  • Strategy settings for SHORTS: 0.21 - 0.22 - 0.23 - 0.24 - 0.25 - 0.26 - 0.27 - 0.28 - 0.29 - 0.3 - LONGS output deviation: 0.032 (3.2%)

  • All other settings are strategy defaults - Broker fees + spread are set at 0.13% per trade


We can see several interesting points:
  • The strategy has very high winrate if set to this objective

  • The settings here have not been “over-optimized”, i.e. all 10 entries are unused, leaving room for larger-than-expected market movements in the future. In this particular case, it is set to favor safety over profitability optimization, but other approaches are possible to maximize profitability.

  • The result is 277.75% , thanks to the strategy's adjustment of position exit levels. With a conventional exit at the moving average, results are only 204.47%, a significant difference.


- How to adjust and apply the strategy? -

  • Generally speaking, the strategy works well on a large proportion of cryptocurrencies, especially for LONG positions. The recommended timeframes are: 30M-45M-1H-2H-3H-4H and the most appropriate timeframe will vary according to the cryptocurrency. It is also possible, with certain assets, to run the strategy on shorter timeframes such as 5M or 15M with success.

  • The strategy can be used with a single position entry level, maximizing capital utilization on each trade and/or having several strategies active on a single account at the same time

  • It can also be used in a “safe” way, using up to ten successive entries to smooth out unforeseen market movements and minimize risk as much as possible. In this case, enter positions with 1/10 of the capital each time, for a setting of ten entries, and give preference to a single active bot per account so that all positions can be covered (a fixed dollar amount, not a percentage, is then recommended)

  • The recommended leverage is x1 or x2 for controlled long-term trading, especially with ten entry levels, although sometimes higher leverage could be considered with controlled risk.


Here's how to set up the strategy:
  • Start by finding a cryptocurrency displaying a nice curve with the default settings

  • Then try out the default settings on all timeframes, and select the timeframe with the best curve or the best result

  • Deactivate shorts

  • Set the first long triggerlevel to the value that gives the best result

  • (optional): Change the moving average type, period and data source to find the most optimized setting before proceeding to the next step

  • Set the 10thlong inputlevel to the last value modifying the result

  • Set the 8 intermediate input levels, distributing them as evenly as possible

  • Then adjust the output level of the longs, which can greatly improve the results

  • Temporarily deactivate the longs, activate the shorts and follow the same process

  • Reactivate longs and shorts


- How to program robots for automated trading using this strategy -

If you want to use this strategy for automated trading, it's very simple. All you need is an account with a cryptocurrency broker that allows APIs, and an intermediary between TradinView and your broker who will manage your orders.

Here's how it works:
  • On your intermediary, create a bot that will manage the details of your orders (amount, single or multiple entries, exit conditions). This bot is linked to the broker via an API and will be able to place real orders. Each bot has four different signals that enable it to be activated via a webhook. When one of the signals is received, it executes the orders for you.

  • On TradingView, set the strategy to a suitable asset and timeframe. Once set, enter in the strategy parameters the signals specific to the bot you've created. Confirm and close the parameters.

  • Still on TradingView, create an alarm based on your set strategy (on the strategy tester). Give the alarm the name of your choice and in “Message” enter only{{strategy.order.comment}}.

  • In alarm notifications, activate the webhook and enter the webhook of your trading intermediary. Confirm the alarm.

  • As long as the alarm is activated in TradingView, the strategy will monitor the market and send an order to enter or exit a position as soon as the conditions are met. Your bot will receive the instruction and place orders with your broker. Subsequent changes to the strategy settings do not change those stored in the alarm. If you wish to change the settings for one of your bots, simply delete the old alarm and create a new one.

Note: In your bot settings, on your intermediary, make sure to allow: - Multiple inputs - A single output signal to close all positions - Stoploss disabled (if necessary, use the strategy one)
Release Notes
TopBot Anomaly (Pro) update of 10/11/2024:

This major update brings several additional features to the strategy:
  • Single-entry “Swing-Trading” mode still based on MA deviations
  • New display and user interface
  • Position size calculations as % of available capital (or as percentage of total capital or cash): For a setting of 10% per entry and initial capital of $1,000, first entry at 10% x $1,000 = $100 - Second entry at 10% x $900 (available) = $90 - Etc - As in real conditions, leverage is taken into account separately.
  • "Accelerate calculations” option: Disables all displays during settings to save time on backtest calculations.


Example 1 - Strategy in Classic Trading mode :
10 entries per direction possible (in this example 5) - Adjustable MA exits (or return to basic MA) - Longs and shorts at the same time or separately.

- L3USDT.P - BITGET - 5M - SMA Lenght : 33 - Trading Mode : LONG & SHORTS (Exit by Deviations) - SL-LONGS : 100% - SL-SHORTS : 100% -
- EXIT LONG : 0.026 - LONGS : 0.029 - 0.035 - 0.04 - 0.045 - 0.05 - EXIT SHORTS : 0.1 - SHORTS : 0.028 - 0.035 - 0.04 - 0.045 - 0.05 -
- Amount : PERCENT (avaliable balance, 20 %, Leverage 2x (1/5 Equity By Entry for 5 positions each side) - Backtest : 03/09/2024 - 03/11/2024 -

snapshot


Example 2 - Strategy in Swing-Trading mode :
A new strategy mode with two separately adjustable MA deviations

- L3USDT.P - BITGET - 5M - SMA Lenght : 33 - Trading Mode : - Swing Trading - - SL-LONGS : 100% - SL-SHORTS : 100% -
- SWING SHORT ENTRY : 0.03 - SWING LONG ENTRY: 0.029
- Amount : PERCENT (total balance), 100, Leverage 1x - Backtest : 03/09/2024 - 03/11/2024 -

snapshot


New comprehensive user interface :
snapshot
Moving Averages

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 Trading-Bot-France 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

To obtain access to this strategy and learn how to use and fully automate it : http://www.trading-bot.fr

Want to use this script on a chart?

Warning: please read before requesting access.

Access to the strategy and free training on how to make the most of it and fully automate it on your broker on our website: trading-bot.fr

Disclaimer