Getting Weekly/Mont...
 
Notifications
Clear all

Getting Weekly/Monthly open

3 Posts
3 Users
2 Likes
997 Views
twofivenine
(@twofivenine)
Posts: 1
New Member User
Topic starter
 

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

 
Posted : 18/04/2021 6:14 pm
Topic Tags
joeffrenz
(@joeffrenz)
Posts: 7
Active Member User
 

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

 
Posted : 18/04/2021 8:49 pm
snoperg
(@snoperg)
Posts: 15
Admin Admin
 

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.

 
Posted : 18/04/2021 9:32 pm
Share: