How to manage thresholds when backtesting against many coin pairs

The problem – it’s just so annoying….

Something that always bugs me is when I have to track different thresholds (the values that determine when indicators / events should trigger a buy or sell) when testing against multiple coins. I would end up with endless commented lines such as:

//if(rsi>80){ //usdtbtc

if(rsi>70){ //btcsia

Now typically you should be putting these thresholds into your config rather than hard coding them. For example:

config.Pumprider = {
historySize: 10,

So great, now I have to comment out lines in the config now, or have multiple configs. Whichever way you work, this is a really annoying and messy problem.

What’s the solution?

I think it makes a lot of sense to stick to using the thresholds in the config so I am using this:

config.zuki_linreg_slope = {


btcethlong: 0.0002,
btcethshort: 0.0002,
btcdgblong: 0.00000001,
btcdgbshort: 0.00000001



Then in my strategy I include this in the header:

var long = 0;
var short = 0;
var exchange =;
var currency =;
var asset =;

and then this in the init:

let pair = currency.toLowerCase()+asset.toLowerCase();
let thresholdkeylong = pair+”long”;
let thresholdkeyshort = pair+”short”;
long = this.settings.thresholds[thresholdkeylong];
short = this.settings.thresholds[thresholdkeyshort];

Then we use long and short in our buy/sell logic:

if (hasbought===false && ema < long ){ }else if (hasbought=== true && ema> short){ //DGB


What’s actually happening?

Essentially we set a currency/asset based set up thresholds, identify the currency/asset pair being used in a backtest using the object, then used this to grab the right threshold values. In this case we assign the values to Long and Short, this is good for a simple example, but of course you could extend this to anything that is coin pair specific.

As a super cool side benefit this made testing with this gekko multi batch backtesting tool a dream.