3 time frames and the same indicator

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

3 time frames and the same indicator

Postby arnie » 25 Feb 2011

I have 3 time frames of the same symbol in one chart, and I'd like to know, for example, when the MACD histogram crosses the zero line in all 3 frames at the same time or other condition.

How can I do this?
Is it possible to do this?

Regards.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: 3 time frames and the same indicator

Postby TJ » 25 Feb 2011

I have 3 time frames of the same symbol in one chart, and I'd like to know, for example, when the MACD histogram crosses the zero line in all 3 frames at the same time or other condition.

How can I do this?
Is it possible to do this?

Regards.
it is possible.

There are many ways to do it.
One easy way is to duplicate MACD 3 times into a single indicator, once for each data series.

Be sure to change the input/variable names to something that is easy to trace,
eg. FastLength_1, FastLength_2, FastLength_3, etc., to correspond with data1, data2, data3.

see post #4 for more help
Multi-Data Analysis
viewtopic.php?f=16&t=6929

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: 3 time frames and the same indicator

Postby arnie » 25 Feb 2011

Hi TJ.

Thanks for the links.

In the Essencials.pdf we read:
The only restriction is that you cannot create multi-data charts using tick or volume bar intervals. Only time
based (minute, daily, weekly, monthly) intervals can be used to create multi-data charts.
Is that limitation only for TS or also MC?
I'm using a 250, 500, and 1000 volume charts.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: 3 time frames and the same indicator

Postby TJ » 25 Feb 2011

Hi TJ.

Thanks for the links.

In the Essencials.pdf we read:
The only restriction is that you cannot create multi-data charts using tick or volume bar intervals. Only time
based (minute, daily, weekly, monthly) intervals can be used to create multi-data charts.
Is that limitation only for TS or also MC?
I'm using a 250, 500, and 1000 volume charts.
The limitation is for TS only.

With MultiCharts, you can mix tick, minute, second, volume bar, etc., into the SAME chart.

Spaceant
Posts: 254
Joined: 30 May 2009
Has thanked: 1 time
Been thanked: 3 times

Re: 3 time frames and the same indicator

Postby Spaceant » 25 Feb 2011

Arnie,

Share with us for your code and finding if possible. In fact, I have been thinking to test this kind of strategy to see if it is worth to investigate more.

Sa

User avatar
arnie
Posts: 1594
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 514 times

Re: 3 time frames and the same indicator

Postby arnie » 26 Feb 2011

Hi.

I've just finished the first draft of what I've been thinking of:

Code: Select all

{***** CCI reading on 3 different volume bar frames, 250, 500, 1000 *****}
{***** 26-02-2011 *****}

//-- start // inputs
inputs:
CCILength (20),
BarNumber_ (6),
PlotData1 (true),
PlotData2 (false),
PlotData3 (false),
Arrow6Color (white);
//-- end --//

//-- start --// variables
variables:
counterUpBarsDT1 (0),
counterUpBarsDT2 (0),
upBarsCounterDT2 (0),
counterUpBarsDT3 (0),
upBarsCounterDT3 (0),
counterDownBarsDT1 (0),
counterDownBarsDT2 (0),
downBarsCounterDT2 (0),
counterDownBarsDT3 (0),
downBarsCounterDT3 (0),
div2 (0),
div3 (0),
upCountDT1 (false),
upCountDT2 (false),
upCountDT3 (false),
downCountDT1 (false),
downCountDT2 (false),
downCountDT3 (false),
data1UpARW (0),
data1DnARW (0),
data2UpARW (0),
data2DnARW (0),
data3UpARW (0),
data3DnARW (0),
data1CCI (0),
data2CCI (0),
data3CCI (0),
data1Interval (0),
data2Interval (0),
data3Interval (0),
counter (0);
//-- end //

//-- start --// bar intervals for each data series
data1Interval = barinterval of data1;
data2Interval = barinterval of data2;
data3Interval = barinterval of data3;
//-- end --//

//-- start --// CCI for each data series
data1CCI = CCI(CCILength) of data1;
data2CCI = CCI(CCILength) of data2;
data3CCI = CCI(CCILength) of data3;
//-- end --//

//-- start --// data series counter above and below zero line - DATA1
if data1CCI > 0 then begin
downCountDT1 = false;
upCountDT1 = true;
counterUpBarsDT1 = counterUpBarsDT1 + 1;
counterDownBarsDT1 = 0;
end
else begin
upCountDT1 = false;
downCountDT1 = true;
counterDownBarsDT1 = counterDownBarsDT1 + 1;
counterUpBarsDT1 = 0;
end;
//-- end --//

//-- start --// data series counter above and below zero line - DATA2
if data2CCI > 0 then begin
downCountDT2 = false;
upCountDT2 = true;
counterUpBarsDT2 = counterUpBarsDT2 + 1;
counterDownBarsDT2 = 0;
end
else begin
upCountDT2 = false;
downCountDT2 = true;
counterDownBarsDT2 = counterDownBarsDT2 + 1;
counterUpBarsDT2 = 0;
end;
//-- end --//

//-- start --//data series counter above and below zero line - DATA3
if data3CCI > 0 then begin
downCountDT3 = false;
upCountDT3 = true;
counterUpBarsDT3 = counterUpBarsDT3 + 1;
counterDownBarsDT3 = 0;
end
else begin
upCountDT3 = false;
downCountDT3 = true;
counterDownBarsDT3 = counterDownBarsDT3 + 1;
counterUpBarsDT3 = 0;
end;
//-- end --//

//-- start --// DATA2 "normalized" counter
if data1Interval <> 0 then
div2 = data2Interval / data1Interval;
upBarsCounterDT2 = counterUpBarsDT2 / div2;
downBarsCounterDT2 = counterDownBarsDT2 / div2;
//-- end --//

//-- start --// DATA3 "normalized" counter
if data1Interval <> 0 then
div3 = data3Interval / data1Interval;
upBarsCounterDT3 = counterUpBarsDT3 / div3;
downBarsCounterDT3 = counterDownBarsDT3 / div3;
//-- end --//

//-- start --// plot DATA1 CCI histogram and a "N" bar arrow
if PlotData1 = true then begin
if CounterupBarsDT1 <> CounterupBarsDT1 [1] and CounterupBarsDT1 = BarNumber_ then begin
data1UpARW = arw_new_self_s(date, time_s, 0, true);
arw_setlocation_s(data1UpARW , date, time_s, data1CCI);
arw_setstyle(data1UpARW , 8);
arw_setcolor(data1UpARW , arrow6Color);
end;

if counterdownBarsDT1 <> counterdownBarsDT1 [1] and counterdownBarsDT1 = BarNumber_ then begin
data1DnARW = arw_new_self_s(date, time_s, 0, false);
arw_setlocation_s(data1DnARW , date, time_s, data1CCI);
arw_setstyle(data1DnARW ,8);
arw_setcolor(data1DnARW , arrow6Color);
end;

Plot1(data1CCI,"data1CCI - Hist.");
end;
//-- end --//

//-- start --// plot DATA2 CCI histogram and a "N" bar arrow
if PlotData2 = true then begin
if upBarsCounterDT2 <> upBarsCounterDT2[1] and upBarsCounterDT2 = BarNumber_ then begin
data2UpARW = arw_new_self_s(date, time_s, 0, true);
arw_setlocation_s(data2UpARW , date, time_s, data2CCI);
arw_setstyle(data2UpARW , 8);
arw_setcolor(data2UpARW , arrow6Color);
end;

if downBarsCounterDT2 <> downBarsCounterDT2[1] and downBarsCounterDT2 = BarNumber_ then begin
data2DnARW = arw_new_self_s(date, time_s, 0, false);
arw_setlocation_s(data2DnARW , date, time_s, data2CCI);
arw_setstyle(data2DnARW ,8);
arw_setcolor(data2DnARW , arrow6Color);
end;

Plot2(data2CCI,"data2CCI - Hist.");
end;
//-- end --//

//-- start --// plot DATA3 CCI histogram and a "N" bar arrow
if PlotData3 = true then begin
if upBarsCounterDT3 <> upBarsCounterDT3[1] and upBarsCounterDT3 = BarNumber_ then begin
data3UpARW = arw_new_self_s(date, time_s, 0, true);
arw_setlocation_s(data3UpARW , date, time_s, data3CCI);
arw_setstyle(data3UpARW , 8);
arw_setcolor(data3UpARW , arrow6Color);
end;

if downBarsCounterDT3 <> downBarsCounterDT3[1] and downBarsCounterDT3 = BarNumber_ then begin
data3DnARW = arw_new_self_s(date, time_s, 0, false);
arw_setlocation_s(data3DnARW , date, time_s, data3CCI);
arw_setstyle(data3DnARW ,8);
arw_setcolor(data3DnARW , arrow6Color);
end;

Plot3(data3CCI,"data3CCI - Hist.");
end;
//-- end --//
The way I see it, and please bare with me since this multi-frame reading is a new world for me, I need to do some sort of normalization between the 3 frames so they can give useful readings.

The way I thought was this (between lines 107 and 119):

Code: Select all

//-- start --// DATA2 "normalized" counter
if data1Interval <> 0 then
div2 = data2Interval / data1Interval;
upBarsCounterDT2 = counterUpBarsDT2 / div2;
downBarsCounterDT2 = counterDownBarsDT2 / div2;
//-- end --//

//-- start --// DATA3 "normalized" counter
if data1Interval <> 0 then
div3 = data3Interval / data1Interval;
upBarsCounterDT3 = counterUpBarsDT3 / div3;
downBarsCounterDT3 = counterDownBarsDT3 / div3;
//-- end --//
Please see attached image.
On the left we have the 3 data series, with the CCI plotting the data2 series.
On the right we have the 500 volume bar and the CCI indicator, which is posted at the end of this post.

Since we are reading data2, and it is a 500 volume bar chart, and since the base chart is the 250 volume bar, we need 2 250V bars for each 500V bar, hence the 2 CCI bars per 1 500V bar (seen on the left chart).

Since my goal here is to count the CCI bars, hence my necessity to normalize the readings, when I select bar number 6 on the left chart, I see the "real" 6th CCI bar, based on the 500V reading and not based on the 250V reading before the normalization.

Now, a strange thing is happening that I couldn't understand yet.
If we compare the arrow on the left with the arrow on the right (using the Track Time and Price tool), the 6th bar, although placed on the correct bar, is actually the 7th CCI bar on the right chart.

Am I missing something?

Code: Select all

{***** CCI indicator *****}
{***** 11-11-2010 *****}

//-- start --// inputs
inputs:
CCILength (20),
BarNumber_ (6),
PlotHistogram (true),
Plot1stLine (false),
Arrow6Color (white);
//-- end --//

//-- start --// variables
variables:
countBars (0),
counterBars (0),
resetCount (false),
myCCI_1 (0),
myCCI_2 (0),
counterUpBars (0),
counterDownBars (0),
upCount (false),
downCount (false),
cci6thUpARW (0),
cci6thDnARW (0),
cci11thUpARW (0),
cci11thDnARW (0);
//-- end --//

//-- start --// CCI length
myCCI_1 = CCI(CCILength);
//-- end --//

//-- start --// CCI bar counter
if myCCI_1 > 0 then begin
downCount = false;
upCount = true;
counterUpBars = counterUpBars + 1;
counterDownBars = 0;
end
else begin
upCount = false;
downCount = true;
counterDownBars = counterDownBars + 1;
counterUpBars = 0;
end;
//-- end --//

//-- start --// plot an up and down arrow on the "N" CCI bar
if counterUpBars = BarNumber_ then begin
cci6thUpARW = arw_new_self_s(date, time_s, 0, true);
arw_setlocation_s(cci6thUpARW, date, time_s, myCCI_1);
arw_setstyle(cci6thUpARW, 8);
arw_setcolor(cci6thUpARW, arrow6Color);
end;

if counterDownBars = BarNumber_ then begin
cci6thDnARW = arw_new_self_s(date, time_s, 0, false);
arw_setlocation_s(cci6thDnARW, date, time_s, myCCI_1);
arw_setstyle(cci6thDnARW,8);
arw_setcolor(cci6thDnARW, arrow6Color);
end;
//-- end --//

//-- start --// plot CCI
if PlotHistogram = true then begin
plot1(myCCI_1,"Histogram");

if myCCI_1 > 0 then
SetPlotColor(1, green)
else
SetPlotColor(1, red);
end;

if Plot1stLine = true then begin
plot2(myCCI_1,"1stLine");

if myCCI_1 > 0 then
SetPlotColor(2, green)
else
SetPlotColor(2, red);
end;
//-- end --//

plot4(200,"+200");
plot5(100,"+100");
plot6(-100,"-100");
plot7(-200,"-200");
Regards,
Fernando
Attachments
multi-frame-reading.gif
(49.46 KiB) Downloaded 1230 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: 3 time frames and the same indicator

Postby TJ » 26 Feb 2011

Fernando:
Nice codes! nicely organized.
Thanks for sharing.


I see both charts the same, with the arrows at the same position.
The chart on the left has duplicate bars, because of the 250 CVB data series.
Otherwise they are the same.

Regards
TJ


Return to “User Contributed Studies and Indicator Library”