No one has replied
You may post code snippets. That's what this is for. In any case this is not a code check service.
Suggestion: read the Docs - Quickstart Access an comparison is done several times with a Simple Moving Average
I see your use of get_ylim() and set_ylim() but could not find a parameter that would take advantage of this. Seems you use it for volume for this exact purpose.
Great stuff @backtrader, thanks for the education
Such calculation is probably what's already being done: the unleveraged value.
The idea seems to be to swap the current value with the current unleveraged value, so that the actual value curve doesn't spike. The leveraged value would still be accessible.
It makes sense