SetScaleCompressed for Days/Weeks?
Author: karla2010
Creation Date: 9/1/2011 1:06 PM
profile picture

karla2010

#1
Maybe I've missed how to do this, but it appears there is no way to create intra-week or intra-month bars. My apologies if I've overlooked something.

Is it possible to create something like SetScaleCompressed for days instead of intra-day inputs? Right now there are no intermediate bars between days and weeks.

The same can be said in jumping from weeks to months.

I find superimposing the output from several timeframes (different bar samples) in a single chart, a rough approximation to Fourier analysis, gives a more reliable trend to the underlying indicator.
profile picture

Cone

#2
See: SetScaleDaily(), SetScaleWeekly(), SetScaleMonthly()

But if you want actual Fourier analysis, check out:
Measuring Cycle Periods (Ehlers)
Corona Charts (Ehlers)


profile picture

karla2010

#3
Cone,

Thanks for the reply. I am familiar with SetScaleDaily() etc and maybe don't know how to use them properly. For example my understanding is that SetScaleDaily() is for use within an intra-day chart. I do not believe I can take SetScaleDaily() and add the following SetScaleDaily(3) and get 3 day bars for use within a daily chart. If my understanding is wrong let me know. Hopefully it is clear that what I would like to do is use a SetScaleCompressed type idea within a Daily chart.
profile picture

Cone

#4
Right, there's no days, weeks, or months parameters for those SetScale functions, so multiple-period scaling isn't possible "out of the box".

But if you're a motivated programmer, it's certainly possible to write a routine that does it. The process could go as follows, assuming you want to create an indicator based on a 3-day chart.

1. Create your 3-day (for example) compressed series for the Close, High, etc., but "pack it" at the end of a new series. In other words, you have to work in the context of a DataSeries, so if the chart is Daily, then you would populated only 1/3 of the series with values and ignore the rest.

2. Apply your indicator to the 3-day series.

3. Synchronize to the base chart's time frame. You'll actually have to prepare for this in Step 1 by creating another Series or array with Date values that correspond to the 3-day series.

After having gone through this thought process, it sure seems like I've already done this before. If you're lucky, you might be able to find the code in the forum.
profile picture

karla2010

#5
Cone,

The following code creates an arbitrary compressed interval bar based on daily data and synchronized with the base Daily bar. The compressed Bar in this example is called Bm.

The question is what to do about filling in the series to match the base sample rate, in between the compressed bars. For the Open, there is no issue. The Close and Volume entries, are a weighted combination between the last compressed bar and whatever the base bar is doing. The High and Low track the base bar finding the lowest and highest value in the intermediate interval.

The example creates 3 Day Bars but by changing the mbf variable any compressed daily bar can be modeled.

This seems to work. If you see any errors please let me know.

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).