Strategy Optimization Steps
Hey Mathieu, have been playing with your library, very promising!!
I have some questions I have you can help me figure out:
- how to download a specific time range/timeframe of data before starting a strategy backtest
- how to select and get the strategy inputs
- how to set the ranges of inputs for which to backtest the strategy
instead of backtest inputs "2", input ranges: "2-5" with step size: "1", for example
- how to export the performance summary for every combination of inputs
When backtesting in the browser, changing the inputs instantly updates the performance summary. You think this is run in the browser? Or does it actually come from the server this fast?
have you tested if this can be done multithreaded? do they throttle you?
Super excited about this! would mean i no longer have to code in EasyLanguage to optimize :)
hey @robert-hopla ,
- You can set the
timeframeandrange(# of periods) in setMarket'soptionsparameter. - I was able to get the indicator / strategy id from this URL: https://pine-facade.tradingview.com/pine-facade/list/?filter=standard (the
scriptIdPartof the response.) - Here's a sample code of how you would get the performance summary of a strategy:
const TradingView = require('../main');
const fs = require('fs');
/*
This example tests fetching chart
data of a number of candles before
or after a timestamp
*/
const client = new TradingView.Client();
const chart = new client.Session.Chart();
chart.setMarket('BINANCE:BTCEUR', {
timeframe: '60',
currency: 'EUR',
});
TradingView.getIndicator('STD;Bollinger%1Bands%1Strategy').then(async (indic) => {
console.log(`Loading '${indic.description}' study...`);
const study = new chart.Study(indic);
study.onUpdate(() => {
const performance = SUPERTREND.strategyReport.performance;
console.log('performance', performance);
client.end();
});
});
how to download a specific time range/timeframe of data before starting a strategy backtest
how to set the ranges of inputs for which to backtest the strategy
You can use Fake replay mode or Real replay mode.
how to export the performance summary for every combination of inputs
There is no shortcut, you have to test them all. You can do it synchronously or asynchronously, it doesn't matter.
When backtesting in the browser, changing the inputs instantly updates the performance summary. You think this is run in the browser? Or does it actually come from the server this fast?
The PineScript engine is server-side.
have you tested if this can be done multithreaded? do they throttle you?
I've never had a throttling issue. I advise against abusing it anyway.
All you need is in the ./examples directory.