Custom bar frequency
Author: kelvinyip
Creation Date: 1/3/2021 3:12 PM
profile picture

kelvinyip

#1
For intraday bars, we have the out of the box 30mins, 60 mins and even custom on the left panel, for higher time frame, we have monthly, weekly and daily. If I want to do make 2 bars in a month or 1 bar per 2 weeks, what the easiest way to do it... any samples ?
profile picture

Eugene

#2
Hi,

To create custom scaling for Daily data like n-Day bars, check out this auxiliary data provider:

EOD Scaling Provider

Make sure you read its online user guide in the Wiki.
profile picture

kelvinyip

#3
If I want to get 1 bar by combining 2 months.. ( not consistently 25 bars per month), is there any trick ?
profile picture

Cone

#4
Since there are typically 21 trading days in a month, how does a 25-bar month work exactly? Does it reuse bars? How is the bar's open and close defined? Clearly this isn't supported, I don't even know where to start! Is there an example somewhere else that you can point to?
profile picture

kelvinyip

#5
Sorry, I meant like 20 or 21 bars.. like July and August (30 days vs 31 days) and twenty something trading days. I want to combine 2 months into 1 bar that's all.
profile picture

Cone

#6
QUOTE:
I want to combine 2 months into 1 bar that's all.

Why are we talking about days? You want 6 bars per year, correct? The open of the first bar is January's open and the close is the last trade in February?

Anyway, the EOD Scaling provider doesn't have an option to support that. What you could do is create the bars yourself, export them as ASCII, and then create an ASCII DataSet with your new bars. That would work.

Can you let us in on why 1-month bars are too "fast"? I'm really curious!
profile picture

kelvinyip

#7
I see, create my own bars and export.. got it. I want to look for inside bars (but not like inside 1 month bar) but a inside bar on a 4 month time frame for example.I saw this guy on twitter https://twitter.com/RobInTheBlack and the gist of it is multiple time frame analysis so I got interested an want to see how it performs backtested. Oh I was asking about days because I see in the doc that's supported... usually you guys have some clever way to get around stuff..
profile picture

Cone

#8
If you don't need to see the bars and only backtest a strategy for inside bars on a 4-month time frame, then you can certainly do that by just programming it in the strategy. Just pick the months you want to trigger on (like 4, 8, and 12) and keep track of the combined OHLC for the last 2 periods. Compare the last two of those. If you want to get fancy, you could even draw the resulting bar using DrawRectangle, DrawLine, etc. on top of a monthly (or any other) chart.
profile picture

kelvinyip

#9
yeah, but like you said also want to see it.. Let me preprocess the data and spit them out to files, that may be easier for me to do.
profile picture

kelvinyip

#10
If I export monthly bars to a file and then use EOD Scaling provider to combine 2 bars into 1, do I get my bimonthly bar and can plot it ? (Trying to get around doing lots of programming)
profile picture

Cone

#11
Try this:
1. Use the Line ChartStyle and decrease the line width to 1
2. Run this script on your monthly (or any) bars.

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).