Coder Social home page Coder Social logo

akumidv / tradingview-assistant-chrome-extension Goto Github PK

View Code? Open in Web Editor NEW
150.0 14.0 51.0 2.64 MB

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

License: GNU General Public License v3.0

JavaScript 75.43% CSS 2.61% HTML 21.88% Shell 0.09%
tradingview chrome-extension backtesting backtesting-trading-strategies

tradingview-assistant-chrome-extension's Introduction

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

Declaimer

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.1 => 2.2:

  • fix for TV UI changes
  • fix for breaking set of strategy parameters if strategy have parameters with identical names

2.0 => 2.1

  • fixed TV UI changed in performance report table that freeze extension

1.16 => 2.0(1.17):

  • deep backtesting - thanks @Murena7 for implementation draft version
  • fixed for chrome memory error (increased possible cycles for backtesting and speed for settiings of parameters)
  • delay for backtesting results (for deep backtesting x2)
  • delay between backtests for reduce TV API load
  • saving in CSV values with more than 2 digits after point
  • fixes for numbers input in nonumbers fields - thanks @TomKaltz for pull request with changes
  • backtesting for timeframes - thanks jarno for suppport this changes in version

Functionality

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

  • automatic getting a list of parameters and their types (numeric, lists and checkboxes are supported)
  • generation of the testing range according to the rule: the beginning value is 2 times less than the current one, the end is 2 times more than the current one.
  • saving the generated parameters of testing a trading strategy for their correction as a template in a file in CSV format
  • Loading adjusted parameter ranges from a CSV file
  • Configuring the optimisation model:
    • Choosing the type of optimisation: searching for the maximum or minimum values
    • Selecting an optimised value from the entire list of strategy results in Tradingview (Net Profit, Ratio Avg Win / Avg Loss, Sharpe Ratio, Sortino Ratio, etc.)
    • Choosing a search strategy in the parameter space(random, sequential, annealing method)
  • Filtering of unsuitable results. For example, the number of tradings is less than necessary
  • Setting the number of cycles to search for parameters.
  • Performing automatic selection of parameters with storing all the results in the browser storage and the ability to save them as CSV files after testing, including in case of an error or page reloading
  • Showing backtesting results on 3d chartto analyze the effect of various parameters on the result.

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 webstroe

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:

  • Trading view indicators – some of them have different formulas to calculate results, for example supertrend, ta.RMA and more others. They need additional implementation and in results they calculated more slowly than if python script would use ta-lib.
  • Implementation of the data parsing. If the data for the crypt is mostly free, but the data of low timeframes is usually paid (for example, eodhistoricaldata). Developer need to implement an interface to them and some process to store and reuse local(cloud) stored data.
  • Difference in data for stock or forex exchanges from Tradingview. Also, for some cryptocurrency exchanges.
  • Adopt framework of backtesting (backtesting, backtrader, vectorbot, etc.) to work with strategy
  • Wrap this code for frameworks of parameter gyperspace optimization (simple example you can see in trade-strategies-backtesting-optimization) and increase speed of backtesting with some methods.

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:

  • tradingview-ta-lib - Tradingview ta lib implementation in python (only for tradingview indecators that have different caclulatoin results with ta-lib or python-ta - early developing stage.
  • catcher-bot - Bot for screening all symbols on excahnges/exchanges and cath trade signals - early developing stage.

Contacts

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

https://linkedin.com/in/akuminov

https://fb.com/akuminov

Regarding contacts via social networks - they are banned in Russia, so I do not answer quickly. Email is preferred way, but usually I do not have the ability to answer quickly (2-3 days delay).

Project development donate

Cryptocurrency transfer information

  • USDT, TRX (TRC20) network TFqv5hB3cdVHxkxhL8qjpfRMbeqMcuwzFP
  • USDT, Matic (Poligon) network: 0x1e2598ff5aa98b83acc92cf2831b452b2c708b27
  • USDT, ETH (ERC20) network: 0x1e2598ff5aa98b83acc92cf2831b452b2c708b27
  • USDT, BSC (BEP20) network: 0x1e2598ff5aa98b83acc92cf2831b452b2c708b27
  • USDT, Sol (Solana) network: CuwuesyM1tyrjyJr9avDrrRqcB4rTbciao5mXYP8HkKo

Binance Pay ID for USDT, USDC, BUSD or other crypto: 240890941 (akumidv)

tradingview-assistant-chrome-extension's People

Contributors

akumidv avatar tomkaltz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tradingview-assistant-chrome-extension's Issues

Problem with filtering

Hello, I have set up a filter with DD max 20% and also with % profit all. When I check the best setting with % profit all I have a max dd of 40%. Recurrence of the problem with version 1.6. thanks

Thank you

Just wanted to stop by and say thank you!

No strategy name element on page

Since a few hours ago i get the error that the extension cannot find the strategy element on the page even though it is visibly open. I think it is because tradingview made some new changes again that the name of the HTML element got changed or something of this sort.
Screenshot with the error and strategy element open:
strategy problem

Screenshot with tradingview changes
strategy problem2
I saved the html code of the page incase that could be useful for you aswell.

Missing column in CSV

Hello
I wanted to merge several CSV files to make one.
When I converted the files to Excel with the "," separation, I realized that the columns were not the same, depending on the file, some columns were missing.
Is it possible to have files with columns that match? Thanks
image

Removing column from the csv result

Hi

First of all, I would like to thank you for this fantastic backtester it's really impressive. I would like to know if it's possible to only show the column we want when your extension generates the CSV file? There is too much useless data for my own need and it would be awesome if we could just delete the column we don't want within the extension or with another method.

Thank

Add help icon to optimiztoin method, also add to readme and extension description.

A sequential optimization method is to adjust 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 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 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.

Full random method - always selects random values for all parameters at once.

Update Sample template

сбстн сабж, в линке зашит шаблон без default и priority
и если возможно добавьте описание этих полей

Cannot convert undefined or null to object

Расширение работает только если tradingview на английском, стоит это указать в описании или решить проблему.
спс.

Аннотация 2021-12-05 162040

Get Template and Test strategy don't detect & manage float params

"Get Template" functionality doesn't manage float values in the strategy parameters. Only integer?

e.g.

// @version=5
strategy(...)
i_multi = input.float(  title='Multiplier', defval=3.1, minval=0.1, step=0.1, group="COEFF", tooltip="Hello Folks!")

Affter a "Get Template", in the Excel I see:

Parameter | From | To    | Step | Default | Priority
Multiplier| 3.1  | 19.6  | 1    | 6.8     | 18

So, I forced Step value to 0.1 and imported into the addin the csv with the helpful "Upload parameters".
When I run "Test strategy", the popup list, that I can see before the execution, shows the active Multiplier param with a step value = 1 and only increments by 1 unit and no 0.1 as expected from the strategy code and from the "Upload parameters" command.
Is there something I'm missing or wrong?

Kind Regards

Extension does not detect some parameters.

Hello,
the extension does detect "AltFilter I and AltFilter II" but it doesn't detect numbers next to it so I am unable to change them in settings.
image
Also, it doesn't detect multiple "short" and "%" values and it show only one short and one %. So once again I cant change it in settings.
image
image
Would be possible to release update that will detect these values that I am missing?
But overall it's insane extension!

result is wrong!!!

Hello, even though the net profit is negative, it takes it numerically and affects the results negatively.

clean best results

this answer is kind of funny. I already know this button. I don't want everything deleted. I only want the best result values to be deleted. I want to keep the parameter settings.... understand?

Extension does not use steps lower than 1.

In the csv file you can specify the step with which the extension will go through the settings, but it does not go below a step of 1 anymore. I will attach a screenshot where it shows i use a 0.1 step for the Stop loss and Take profit but during the tests it only uses steps of 1. It used to work before so i dont know if i did something wrong or if something in the code changed that this isnt posible anymore. I tried to use both 0.1 and 0,1 and neither work.
extension problem5

Cannot read properties of undefined with filter-on for Annealing method

Very good change to have your extension!

I always got error of undefined properties during the backtesting when using filter. It happened to every strategies I tested, though there is no problem without filter (500-1000 iterations). The backtesting parameters could be run for few combinations (~3-10) before it stopped (both less/more filters). It seems some parameters value has gone or not updated during the test.

TV assistant filter error

TV assistant filter error 2
.

Error during install of extension

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist. Error occurs after using load unpacked of chrome extension.

Error message keeps popping up

I keep getting an undefined properies error message. how can i fix this? It happens for th Take profit factor as well as the length.

2022-06-23 08_51_54-Greenshot

2022-06-23 08_50_02-Greenshot

NaN Error

Screen Shot 2022-05-17 at 10 27 41 am

Working yesterday - Not working today... Get this weird NaN error? Thanks

enhancement: Add the option to uncheck ALL checkbox in "Strategy parameters" popup

I've many params to manage (above 50).
Very often I prefer to jump to the "Strategy parameters" window and manage the params directly without doing an export/save before and then import/upload into the addin just to see all the params unchecked apart the ones from the excel file.
When, for example, I change the name or I add a new param in my Strategy and click on "Test strategy" without doing before a "Get Template"/"Upload parameters" the "Strategy parameters" window opens with ALL the params selected.

So, It might be practical to have an option at the top of the checkbox column to quickly deselect everything so that I can only select the parameters I want to test and avoid deselecting all 50 and over parameters by hand first on my list.

Ability to test Watchlist & Timeframes (both or seperate) with static (or parametrization of the strategies)

There is an extension possibly based on yours (based on the design similarities)
ID: emcpjechgmpcnjphefjekmdlaljbiegp
of trader.dev
where there are the options :

  1. To check the whole watchlist with current settings of the strategy
  2. To check a set of timeframes for one pair
  3. (my request) Possibly to check all watchlist pairs in all defined timeframes

The same goes for the Davidd ext. i mentioned before

pageMouseClickEL is not a function

I tryed to run the optimizer on a subset of parameters of a strategy but i randomly get the error pageMouseClickEL is not a function while running.
Does not seems to happen after the same amount of iteration, happens randomly.
image

data error

Returns the error: "There is no data for conversion"

database or csv

Can you store the iondv key information in csv instead of chrome.storage.local? Although I changed the scanning parameters, it scans using the previous settings. I have to clear the parameters, refresh the page and change the parameters again...

or if you cancel the best starting values before starting the test I think my problem will be solved...

Artificial Neural Networks [ANNs] is it possible ?

As I wrote in the title, the annealing method is really nice. It will be much more successful if it can find the right result faster and with less repetitions.
-Also, if you add artificial intelligence to the project, I really get teary-eyed.
-and the project must have a time frame and be scannable.
-Can the right time frame be found first with artificial intelligence or annealing method?
These are the ones that come to my mind now. Thanks in advance. Actually I am a programmer but I know very little javascript.

Error message: Cannot convert undefined or null to object

Hi When running the optimiser the first run seems to run the second raises this error .

Error message: Cannot convert undefined or null to object

An error has occurred.

Reload the page and try again.
You can describe the problem by following the link.

Error message: Cannot convert undefined or null to object

Increase Cycles limit

Hello, Love your extension.
Is there a possibility to test all input parameters with permutation not sequential to be able to test all possible combinations?

Change Tradingview time interval.

Hello again, and thanks for this awesome extension. Is it possible to change settings in Tradingview with the extension? Specifically cycle through the starred (favorites) Time Interval. I would like to be able to run through some, but not all time variables when backtesting.
Untitled

Annealing does not work

When you choose the option of Annealing in the optimizer it gives no data whatsoever. I can see in the strategy tab that it gives the correct % numbers but not in the optimizer screen. I thought it was just a visual bug but when the excel is downloaded it also shows that there was no data collected.
annealing problem
annealing problem2

Results in CSV are not the actual ones and Optimum settings are not applied when cycle stops (manual or auto)

Your script is a daily buddy.
I put him to work and i like to see what he has for me at the end of it.
Something like a puppy with a bone, i through a bone and wait if it can get me iron, silver or gold.

Before few days everything was fine.
Today i noticed that the optimum settings that the popup window report didn't applied to the strategy, when i stopped it manual or the cycle ended normally.

I said OK, no big deal, i will go and sort the csv to find them.
However when i tried to put the settings to the script, the results still didn't match with the CSV.
I used Annealing and Random improvement with Profit Factor all and Net Profit all.

I have the CSVs if you think they can help you. The strategy was the "Grab Trading System"
It has only two parameters (long and short)

Not an issue

I'm trading with Jack Rabbit Tradingview suite of signals, it's a cool mudular signal system and normally the alerts are created on the signals and not on the strategies (the strategies are used only to backtest) due to the misfire that normally happens on singals on strategies expecially on fast timeframes.
I wonder is it's possble to use the assistant to change parameters of signals and check thesults on the strategy.
Thanks !

Use range in filter?

Is it possible also to have range in filter? As GT or LT is only filter @ one side of the parameters while sometimes it should be more appropriate instead of that to specify in range.

Eg. there should be suitable Buy/Sell number of trades not more or less. If we trade too often it got chances that we will loss in accumulated little trades and if we trade too little it got more unreliable long periods for the indicators' time frame.

We can also use filter to imply second target such as max drawdown. In this case we would to minimize it at the same time I don't want it to be zero as it looks not feasible and proof inaccurate for long run.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.