I have a simple strategy script that has a variable N
When there is high volatility or momentum in the market it seems to perform better with a larger N number
When there is lower volatility the equity curve is almost flat.
This made me think it might be an idea to include some kind of volatility code to adjust the N variable.
i.e when volatility is high over X periods: N number increases (and vice versa)
How can I go about and code this?
(if possible, I’d like to keep the code simple and add as little new variables as possible)