akumidv / tradingview-assistant-chrome-extension

An assistant for backtesting trading strategies and checking (showing) external signals in Tradingview implemented as a Chrome browser extension.
GNU General Public License v3.0
158 stars 56 forks source link
backtesting backtesting-trading-strategies chrome-extension tradingview

About

An assistant for backtesting trading strategies and checking (showing) external signals in Tradingview implemented as a Chrome browser extension.

Add to Chrome from webstore

Watch the youtube video

Video how to install extension

Disclaimer

Attention!

Active use of the extension can cause detection by the TradingView as using a bot for backtesting and lead to the ban of the user's account.

Although the extension is not a bot (i.e. it does not work independently of the user in the cloud), it does not use the TradingView API and does not interfere with data transmission, but only automates user behavior through the UI. Its use and all risks remain with the users.

Disclaimer

The developer of the extension does not response for any possible consequences of its use.

Last version changes

2.9.3 > 2.10.0:

Functionality

Backtesting trading strategies, optimisation of the strategy's parameters:

Optimization Methods

The sequential improvements optimization method is implement adjusting the best value already found. It does not perform a complete search of the entire parameter space. The logic of it work is as follows. The current best state (parameters for max results) is taken. The first parameter is taken and all its values in the range are checked sequentially. If the best result is found, then further verification is carried out from this state. Then the next parameter is taken and all its values in the range are checked and etc.

The brute force optimization method implement backtesting all values in strategy space of parameters.

The annealing method is an optimization method in which the search for the maximum possible result is carried out in fewer steps https://en.wikipedia.org/wiki/Simulated_annealing The method works this way: first, the best state and its parameters are determined. One parameter is randomly determined, then its value from range of possible values is randomly selected. The status in this value is checked. If it is better, then it is remembered and further parameter changes are made from it. As the number of tests increases, the spread of parameter values decreases around those already found. That is, if at the beginning of testing the values are randomly selected from the entire range of possible parameter values, then as optimization is carried out, this spread decreases ("cools down") near current values. So in first phase of test - this method is search the most possible state around all space on the finish stage this method trying to improve found best state. So that the system does not get stuck in one parameter area, as it happens with the sequential method, not one random parameter changes periodically, but all at once.

The random improvements method is the simplest. One parameter is randomly determined and then a value is randomly selected for it from the entire range of possible values. If the condition is better, then it is remembered. And then the parameters from this state are randomly changed.

The random method - always selects random values for all parameters at once (default)

Upload external signals to tradingview chart

Loading external buy or sell signals by timestamps from a CSV file*

To display the signals, you need to create a pine script named 'iondvSignals' from the script bellow add it to the chart:

//©akumidv
//@version=4
study("iondv Signals", shorttitle="iondvSignals", overlay=true)
strTSBuy = input("", "TSBuy")
strTSBuy = input("", "TSSell")
tickerName = input("", "Ticker")
var arrTSBuy = str.split(buy_series_time, ",")
var arrTSSell = str.split(sell_series_time, ",")
plotchar(tickerName == syminfo.ticker and array.includes(arrTSBuy, tostring(time)) ? low : na, location = location.belowbar, color=color.green, char='▲')
plotchar(tickerName == syminfo.ticker and array.includes(arrTSSell, tostring(time)) ? low : na, location = location.abovebar, color=color.red, char='▼')

After that, upload the signals from the file created accordingly the template

timestamp,ticker,timeframe,signal
1625718600000,BTCUSDT,1m,BUY
2021-07-27T01:00:00Z,BABA,1H,SELL

The signals are stored in the browser, to activate them, open the properties of the created indicator named 'iondvSignals'.

Setup

Install from Chrome webstore

Or manually add the latest version to chrome based browser from this repository by following the instruction below.

Click on the browser's address bar, insert chrome://extensions and follow this link. Click on the "Developer mode" switch.

The "Load unpacked" button should appear. Click on it, and in the window that opens, select the folder with the saved repository files (you can download them as a zip archive via the link https://github.com/akumidv/tradingview-assistant-chrome-extension/archive/refs/heads/main.zip).

The manifest.json file is located in the root folder of the extension.

Update

Unpack the new version to the same directory as the previous version (it is better to delete the files of the previous version). Go to the extensions tab by following the link chrome://extensions. Click the restart button for the extension.

Issues

Please add issues in this repository by following link.

Very helpfull will be if you can attach full screenshot with tradingview page and errors. And also with open command tab in browser developer mode (please press F12 to open developer mode and click on console tab)

PS

** The field separator for CSV files is a comma.

Recommendation

If your strategy requires a large amount of testing, it is recommended to order its conversion into python and perform backtesting and hyperoptimization of parameters using resources, such as Google Collab or your computer. In addition, it significantly speeds up the search for parameters (in 5-10 times per cycle) and history deep. Examples in Jupyter Notebooks in repository trade-strategies-backtesting-optimization. You can run examples in Google Collab, it's free. You would just upload files with extension *.ipynb to your Google Drive and open these files.

Where transfering from TradingViews scripts usually developer should solve some promblems:

From my experience it demands 2-3 minutes developer time for each row of tradingview script. For example if you have 200 line strategy it would demand ~6 hours to conversion. For some complicated strategies it can deman much more.

To reduce developing time you can use some my repositories:

Contacts

akumidv [at] yahoo.com (Do not send errors to email please, use github issues for them)

https://linkedin.com/in/akuminov

Email is preferred way, but usually I do not have the ability to answer quickly (2-3 days delay).