I would like to count the number of times a stock price dropped 5% in the next 3 months using Amibroker AFL code. I guess this will require using Ref() to reference future values. https://www.amibroker.com/guide/afl/ref.html Can someone provide some hint as a starting point?
I would NEVER use ref function using positive values. Be VERY careful when you use the Ref function to look ahead. Very dangeorus when it comes to backtesting for you are peeking into the future. Why would you want to do that? Why not use Ref(x,-1) to look back using some form of conditional to only count the 5% move? Also use the count function. you can also use custom backtesting interface and create a fake price for the winners and another fake price for the losers so your filter might catch 500 trades, 100 winners which means there were 100 times when stock went down 5%. PM me for more help.