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)
maybe you have a medianvalue where N is not high and not to low?
then you can do N = ATR[x] + medianvalue of N
you can also use the VIXfix (somewhere in the library) instead of ATR?
You have to define first what volatility value you want to use?
Then you can think of a normalization of N upon that value.