Display ATC data in Weekly / Monthly Time Frames

I am creating ATCs in Scan mode, in Daily Time Frame, for the various sectors and displaying them in indicator mode

Sample code for creating the ATCs:
ATCname = "~Sec-" + Sector + "-Stoch"; // where Sector is the sector ID number
AddToComposite( Close, ATCname, "C", atcFlagDefaults | atcFlagEnableInIndicator );

Displaying the ATCs works fine in Daily time frame, but SOME of them are very distorted when I try Weekly or Monthly time frames

The red / green histogram is the Advance / Decline data for the sector .
(Advances - Declines) / (Advances + Declines) * 100
The Blue line is the McClellan Oscillator of Adv/Dec.



Appreciate any feedback

As a follow up to above issue, I did some additional testing and see a strange behavior with ATCs

Writing to ATC in Daily periodicity.

In writing AdvDec data, I wrote the data for advances in 2 fields of ATC ("O" and "V") to verify all fields behave the same way.

Also I wrote the data for declines in 2 fields of ATC ("H" and "L")

When I read the data in a charting program, the data from both fields is identical when I display in daily time frame. When I switch to Weekly of Monthly time frames, the data from the 2 fields of same data, fields ( "O" and "V") or ("H" and "L") diverge significantly.

Below is a sample of weekly chart for fields "H" and "L".

Daily - Display is normal with both traces superimposed perfectly

Weekly - Large divergence. Yellow trace is field "H".
Code below in 2 snippets. First for writing the ATCs and then read ATC and display chart

I assume that:

  • I should be able to view data from ATCs in any timeframe, just like any other data.
  • That same data written in different fields should be reproducible the same way from all ATC fields.
  • Or that my code for writing ATCs has a problem

Please advise


    adv       = Close >= Open;
    dec       = Close <= Open;

    ATCname   = "~Sec-" + Sector + "-AdvDec";
    AddToComposite( Close, ATCname, "C", atcFlagDefaults );
// Fields "O" and "V" have same data
    AddToComposite( adv, ATCname, "O", atcFlagDefaults );						
    AddToComposite( adv, ATCname, "V", atcFlagDefaults );

// Fields "H" and "L" have same data
    AddToComposite( dec, ATCname, "H", atcFlagDefaults );				
    AddToComposite( dec, ATCname, "L", atcFlagDefaults );

Read and Display chart

Adv				= Foreign(ATC_name + "-AdvDec","O");
Adv_V			= Foreign(ATC_name + "-AdvDec","V");
Dec				= Foreign(ATC_name + "-AdvDec","H");
Dec_L			= Foreign(ATC_name + "-AdvDec","L");
//PLot Sector AdvDec Data

Not sure about the problem you are having but i noticed this.

By normal convention, you should not have the equal to operator in both conditions. When Close == Open, should be an either scenario.
It may work for you but then adv + dec in any given bar may not be consistently equal to the total sum of symbols.

If two fields H and L in Daily have 5 different values and compressed to weekly,

Then H of Weekly will he H of the 5 values and similarly L will be Low of the 5 values.
same thing goes for month and so on.
it is normal time compression, i don't think there is any problem. so H will never superimpose on L in higher timeframe.

@ara1 I have not reviewed your codes but you are not using the normal definition of "ADVANCE" or "DECLINE" in your attempt to create the McClellan Oscillator.

    adv       = Close >= Open;
    dec       = Close <= Open;

The Close being greater than the Open is not the usual definition of an advancing stock. The Close being greater than the previous Close is an advancing stock.

AdvanceIssue = C > Ref( C, -1 );
DeclineIssue = C < Ref( C, -1 );

Good luck.

Yes, of course the definition of advance is Adv = C > Ref(C, -1 ); as you indicated.

What was I thinking? Will correct.


nsm51, thanks for your response ,,, the way you explain how ATCs work is completely different from my understanding. I was not aware that the "O", "H", "L", "C" fields of the ATC actually retained the corresponding values of Open, High, Low and Close values when compressed to weekly / Monthly time frames. My understanding was the field letters were just labels.

I tested my formula by moving the Advances to "Aux1" and Declines to "Aux2" and my formula worked properly.

I have not tested fields "V" and "I" yet. I assume that data read from these fields will be correct for all time frames.

Is there a help file somewhere with these details (as I had not appreciated these points from the main help files)


I dont think what i said is specific to ATC but just logical.
If there are 5 values in Daily, and it has to be compressed to Weekly, what is the logical choice ?
Is it the first value, or H, L or last. even running sum like volume ?


mode = compressLast see this parameter.