- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Original Discussion Post: #355
There's something that I noticed which makes it difficult to view indicator graph on the chart if you're backtesting for longer period. Below is an example of an indicator view on the chart without zooming in. Notice the y axis scales.
Now, when I zoom in to focus on a specific period when ttm squeeze value stayed between -5 to +5, it still shows the full scale from -15 to+20. which makes it really hard to visualize the indicator chart. See below.
I know that re-scaling is allowed for the price chart/Volume. Is that something that can be implemented on the indicator charts as well?
ivaigult
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Milestone
Relationships
Development
Select code repository
Activity
zlpatel commentedon May 22, 2021
I fiddled around with the code and made it work :)
Here's what I did:
I have added code
right above
backtesting.py/backtesting/_plotting.py
Line 526 in 0a76e96
then,
right below these lines
backtesting.py/backtesting/_plotting.py
Lines 610 to 611 in 0a76e96
then,
right below these lines
backtesting.py/backtesting/autoscale_cb.js
Lines 30 to 33 in 0a76e96
Here's how it looks on the graph:
Without Zooming in:

When Zoomed in:

[-]Allow Auto-scaling of Y axis values for Indicator(when overlay=False) when you zoom in or out the chart.[/-][+]Auto-scale Y-axis for indicators when zooming[/+]Auto-scale Y-axis for indicators when zooming kernc#356
Auto-scale Y-axis for indicators when zooming kernc#356
Auto-scale Y-axis for indicators when zooming kernc#356
Auto-scale Y-axis for indicators when zooming kernc#356
Auto-scale Y-axis for indicators when zooming kernc#356
Auto-scale Y-axis for indicators when zooming kernc#356
Merge pull request #1 from zlpatel/kernc#356
Auto-scale Y-axis for Profit/Loss chart when zooming kernc#356
Auto-scale Y-axis for PL chart when zooming kernc#356
Add auto scaling of y-axis for PL chart kernc#356
Add whitespace after , to fix lint issue kernc#356
[-]Auto-scale Y-axis for indicators when zooming[/-][+]Auto-scale Y-axis for indicators and Profit/Loss graph when zooming[/+]2 remaining items
Remove y-axis scaling logic for PnL graph kernc#356
Remove y-axis scaling logic for PnL graph kernc#356
[-]Auto-scale Y-axis for indicators and profit/loss graph when zooming[/-][+]Auto-scale Y-axis for indicators graph when zooming[/+]Reverted: Auto-scale Y-axis for Profit/Loss chart when zooming kernc#356
zlpatel commentedon Jun 13, 2021
@kernc can you review my fix for this?
Auto-scale Y-axis for indicators when zooming kernc#356
Merge branch 'kernc#356' of https://github.com/zlpatel/backtesting.py …
Fix indicator index mapping kernc#356
Fix lint issues kernc#356
Fix flake8 formatting issue kernc#356
Auto-scale Y-axis for indicators when zooming kernc#356
lkfrota commentedon Dec 2, 2021
Thank you for the great work. That is something that I was looking for and made the job.
However, did you notice that it works only if the volume is plotted along (i.e. plot_volume=True)?
...or did I miss something (I'm not an experienced user).
zlpatel commentedon Dec 13, 2021
Thanks for pointing it out. I will need to figure out the dependency on volume chart and separate it from it.