Dual Instruments CountBars  [SOLVED]

Questions about MultiCharts and user contributed studies.
tradebuster
Posts: 10
Joined: 30 Jul 2012
Has thanked: 7 times

Dual Instruments CountBars

Postby tradebuster » 20 May 2014

Hi, I have plotted a 3 minute charts and below that a 500 contract chart. Obviously I get more bars plotting on data 2 on the contract chart. How would I count the number of bars that plot on data 2 between 3 minute bars on data1. I can get this data once the bar on the 3 minute has closed.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Dual Instruments CountBars  [SOLVED]

Postby Andrew MultiCharts » 21 May 2014

Hello tradebuster,

Here is a simple example:

Code: Select all

Var: NumberOfBarsOfData2(0);

NumberOfBarsOfData2 = Symbol_CurrentBar of data2;

Difference = NumberOfBarsOfData2 - NumberOfBarsOfData2[1];

tradebuster
Posts: 10
Joined: 30 Jul 2012
Has thanked: 7 times

Re: Dual Instruments CountBars

Postby tradebuster » 21 May 2014

Thanks Andrew ... that was a lot easier than I thought! I spent hours going down this path:

If Barnumber Of Data2 > Barnumber of Data2[1] then Counter = 1 + Counter else
If BarNumber of Data1 = BarNumber of Data1[1] then Counter = 0;

I applied to data2 but it wouldn't reset my counter to 0 hoping it would read that from data1.

Thanks very much!


Return to “MultiCharts”