OPEN-SOURCE SCRIPT

Triple Moving Averages + RSI Divergence + Trade Creator [CSJ7]

Updated
This indicator uses triple moving averages to identify the prevailing trend, and calculates the linear regression of the closing price, and of the RSI, to either confirm the current trend direction, or to identify a potential trade reversal. Additionally, it includes a trade management tool that allows you to rate your trade setup according to your selected entry minimums and preferences, plus you obtain an estimated P&L with profitability metrics of your trade.

The key features are:

  1. Dashboard: Includes entry/exit amounts, prices, quantities, estimated Profit & Loss, ROI, ROE, RRR, insights into market trends, entry conditions, and operational logs.
  2. Trade Setup: Allows you to design your trade in detail. Select entry/exit levels, and let the tool suggest optimal target levels based on your ROI and RRR preferences. Specify your desired stop-loss type, and the tool will present the corresponding price.
  3. Entry Conditions Management: Customize your trade entry prerequisites within the settings. The system evaluates these, offering a Trade Rating and displaying current values and entry statuses in the Entry Conditions table.
  4. Trade Box: Visualize your trade strategy with a trade box that shows in alongside your chart, highlighting potential profit/loss zones and entry price points.
  5. RSI & Close Price Linear Regressions: Calculates the linear regression of RSI and the close prices, since the beginning of the current trend, and presents them directly in the chart and alongside the active trend, to allow you to spot a potential trend continuation or reversal.
  6. Adaptive price levels: The tool calculates the viability, trade rating and P&L based on contextual levels, like moving averages and highest or lowest prices, instead of using fixed prices; this allows for the results to adapt dynamically to market fluctuations, eliminating the need for manual recalibrations and adjustments.
  7. Automatic Trade Side Detection: While manual input is available, the tool can intuitively determine the optimal trade side based on current data.
  8. Market Outlook Events: By using the crossings of the three averages, the tool keeps track of the evolution of the current trend, providing points of interest like when the initial momentum is observed, when the trend initiates, when a potential entry zone starts, when a buy or sell opportunity arises and when the trend ends.
  9. Alerts: You can set up two distinct alerts – one notifies on trend milestones and another for trade initiation conditions. Note: Manual activation is required in the Tradingview dashboard.
  10. Logs: The tool provides a log section where you can find relevant information regarding the operation and any encountered errors via the dashboard's log section.


Usage
  1. Choose your desired ticker and timeframe. If a tradable trend is detected and levels are set correctly, the trade box appears. Incorrect levels will trigger a warning in the error logs.
  2. The tool will suggest the logical trade side, but manual adjustments are possible.
  3. Customize ROI, maximum loss, and RRR in the settings. When in 'Auto', the tool will calculate the target price accordingly.
  4. Adjust leverage to align with your risk and reward parameters.
  5. View linear regressions for trend analysis and spotting RSI divergences.
  6. Manage position sizing and risk in the settings, accounting for broker/exchange fees.
  7. Activate alerts for trade notifications.
  8. Enable 'Show Trade Levels' in settings to get the details of the necessary limit orders for the trade.


In the image below, you can view the expanded Trade Creator Dashboard, the Trade Box, and the Linear Regression Lines:
snapshot
The linear regression lines are colored red when trending downward and green when trending upward.
The labels displaying information related to the entry and exit prices can be hidden, as demonstrated in the image above.

Release Notes
In the image below, you can observe an expanded dashboard featuring the Trade Box and the Entry & Exit Levels, which display the data necessary to create limit orders with your exchange or broker:
snapshot
From the image above, you can discern the following:

  • The Market Outlook events section showcases various milestones throughout the current trend's duration, including the date and time of their first occurrence.
  • The Entry Conditions section includes a Trade Rating, calculated based on the minimum conditions that you can configure in the Settings.
  • The Divergence indicator, found within the Entry Conditions section, is derived from the combined slopes of the Close Linear Regression and the RSI Linear Regression, resulting in either a net positive or net negative slope.
  • The linear regression lines are colored red when trending downward and green when trending upward.
  • The Estimated P&L section displays the Position Sizing settings utilized for the P&L calculations. Additionally, it provides the P&L and profitability metrics for the trade, irrespective of it being a win or loss.
  • The Operation Logs section enumerates significant events from an operational perspective. This list offers insights into the current settings and context of the Trade Creator. Furthermore, the Errors subsection within the Operation Logs section lists any errors that might occur. A common error you might come across is when the selected entry and exit levels are deemed incorrect, prompting adjustments in the Settings section.
  • The Entry & Exit Levels labels indicate the level name, the trade side, whether it's a buy or sell, the quantity to be bought or sold, the price at which the limit order should be placed, and the order value.

Release Notes
The trade's main profitability metrics have been incorporated inside the Trade Box, as it can be seen in following image.

snapshot
Release Notes
Fixed minor bugs.
Release Notes
Fixed bug.
Linear RegressionRelative Strength Index (RSI)Triple Exponential Moving Average (TEMA)

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer