Skip to content

Commit 7792588

Browse files
authored
Auto-scale Y-axis for indicators when zooming kernc#356
1 parent 0581c55 commit 7792588

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

backtesting/autoscale_cb.js

+13
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,18 @@ window._bt_autoscale_timeout = setTimeout(function () {
3131
max = Math.max.apply(null, source.data['Volume'].slice(i, j));
3232
_bt_scale_range(volume_range, 0, max * 1.03, false);
3333
}
34+
35+
if(indicator_ranges){
36+
let keys = Object.keys(indicator_ranges);
37+
for(var count=0;count<keys.length;count++){
38+
if(keys[count]){
39+
max = Math.max.apply(null, source.data[keys[count]+'_max'].slice(i, j));
40+
min = Math.min.apply(null, source.data[keys[count]+'_min'].slice(i, j));
41+
if(min && max){
42+
_bt_scale_range(indicator_ranges[keys[count]], min, max, true);
43+
}
44+
}
45+
}
46+
}
3447

3548
}, 50);

0 commit comments

Comments
 (0)