Hello there:
I have been learning trading for a while, and I was thinking about a mean reverting strategy. In order for this to work out, we need to have a stocks that is moving with the mean and standard deviation that do not vary too fast with time , right?.
But how do you exactly translate that into a code??
Thanks
calcola la medi del periodo oggetto di esame, calcola successivamente la std. (deviazione standard) del periodo analizzato.
Thanks for helping out your fellow learners at Quantra, Irene!
thanks a lot… even thought I didn't understand very well…(What language is that?? Italian?)
Hello Ghery,
As Irene correctly pointed out earlier, you can simply compute the average of the price series for a particular time window. Following this, you can calculate the standard deviation from the mean for the period.
On the other hand, if you are looking for a more dynamic approach, it would be recommended to use the Bollinger Bands for this very purpose.
I hope this clarified your doubt and that you are confident in implementing the same.
Thanks a lot… But what I mean was exatly… how do you consider the bollinger bands to not vary too much with time ( if I should use the chart I would say this should look like horizontal lines , but in terms of coding… what criteria is generally used,??)
Hi Ghery,
The Bollinger bands are known to exhibit 4 distinct phases. These include:
Bollinger Squeeze - Indicates prices are consolidating or in a sideways phase.
Bollinger Expansion - Signals an increase in volatility and possibly the start of a trend.
Bollinger Continuation - Represents a clear and stable trending phase.
Bollinger Contraction - Points to the gradual decrease in volatility and possibly the end of a trend
All of the above phases can be determined by studying the interesting factor - Bollinger Bandwidth.
You can imagine the values of Bollinger Bandwidth fluctuating in a range (just like the RSI does).
If the moving average of the Bollinger Bandwidth values is on the lower end of the range, you can conclude that the prices are currently in the Bollinger Squeeze phase - and thus, moving in a sideways manner.
On the other hand, if the moving average of the Bollinger Bandwidth is constantly at the upper end of the range, we can say that the bands are expanding and that prices exhibit high volatility or some type of trend.
You can check the following article to learn more about the concept of Bollinger Bandwidth:
https://blog.quantinsti.com/bollinger-bands/
I hope this clears your doubt.