You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
here an example of how to use parameters with permutations.
First of all, you need to pass the parameters you want to permute. For example, in the following scenario, both lowSMA and highSMA have multiple values. I could also have lowSMA as 10 and highSMA as an array, but let's make things a bit more complicated.
In this case, we'll have 6 permutations. The "demo" strategy will operate as if there is only one pair of lowSMA and highSMA values at a time. So first low: 10 and high: 30, then low: 10 and high: 40, then low: 10 and high: 50, and so on.
Here the code:
import{BTH}from'@backtest/framework'exportconstproperties={params: ['lowSMA','highSMA'],dynamicParams: false}exportasyncfunctionrunStrategy(bth: BTH){if(bth.tradingCandle){constlowSMAInput=bth.params.lowSMAconsthighSMAInput=bth.params.highSMA// Here your strategy ..}else{// Here is your code to analyze the potential support candles,// if they have been defined (aka supportHistoricalData)}}
In the end, the strategyResult structure will contain all the permutations created with various data, such as sharpe ratio, maximum/minimum drawdown, number of candles, and, of course, the end amount.
This way, parsed will contain other useful information about the various permutations executed. Of course, if you want significantly more detail (e.g., all executed orders with notes, each individual gain/loss per transaction, etc.), then it is necessary to execute the strategy without permutation.
Essentially, with permutation, it is possible to run challenges between different values and evaluate the effectiveness of the strategy in the initial analysis. To investigate more thoroughly, you can execute the single strategy with the best individual values for even more accurate details.
NB: If you want to use or visualize these data, you might want to check out backtestjs/command-line. The README for this project includes images of the charts created, so you can get an idea of what I mean.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
here an example of how to use parameters with permutations.
First of all, you need to pass the parameters you want to permute. For example, in the following scenario, both lowSMA and highSMA have multiple values. I could also have lowSMA as 10 and highSMA as an array, but let's make things a bit more complicated.
In this case, we'll have 6 permutations. The "demo" strategy will operate as if there is only one pair of lowSMA and highSMA values at a time. So first low: 10 and high: 30, then low: 10 and high: 40, then low: 10 and high: 50, and so on.
Here the code:
In the end, the
strategyResult
structure will contain all the permutations created with various data, such as sharpe ratio, maximum/minimum drawdown, number of candles, and, of course, the end amount.Something like this:
It is possible to access a summary structure in this way:
This way,
parsed
will contain other useful information about the various permutations executed. Of course, if you want significantly more detail (e.g., all executed orders with notes, each individual gain/loss per transaction, etc.), then it is necessary to execute the strategy without permutation.Essentially, with permutation, it is possible to run challenges between different values and evaluate the effectiveness of the strategy in the initial analysis. To investigate more thoroughly, you can execute the single strategy with the best individual values for even more accurate details.
NB: If you want to use or visualize these data, you might want to check out backtestjs/command-line. The README for this project includes images of the charts created, so you can get an idea of what I mean.
Beta Was this translation helpful? Give feedback.
All reactions