Hi! If is it possible to get monthly or weekly price data for backtesting? I want to try setting a buy filter when last > monthly open. Can I use ref to get current week/monthly data if I use ref(close,5) or ref(close,30) for monthly?
Thanks
Hi twofivenine,
Try this code. You can use this on weekly and monthly data by changing the chart timeframe.
Hope this help!
//Buying Conditions - Buy if last price is greater or higher than the current candle's opening price
Set BuyCondition = IF(last>open,1,-1)
//1 means true (last > open)
//-1 means false (last < open)
//Buy when last price is greater than open
Set Buy = BuyCondition == 1
//Set your sell signal here
REF can be used to reference previous bars. 5 can be used for weekly since we have only 5 trading days in a a week and 20 days for a month. Close > Ref(Close,20) means you are comparing current close to 20 days ago Close. You cant use REF if you want monthly/weekly Opening.