# Calling CCI in MTF

Category:
0
0

Hi Pete. You came to my rescue last week with a snippet of code I was having trouble with and got me back on track. I really didn’t want to bother you again as I don’t want to monopolize your time, but I have an error that I just can’t seem to get rid of. I’ve tried everything I can think of. I hope you don’t mind. Here’s the code and the issue is in the last 2 lines when I try to call the CCI. Thank you in advance.

def agg2 = AggregationPeriod.TWO_MIN;
def agg5 = AggregationPeriod.FIVE_MIN;

input CCIlength = 14;
input CCITlength = 6;
input CCI50length = 50;

def CCIprice = (close + low + high);
def linDev = LinDev(CCIprice, CCIlength);
def CCI = if linDev == 0 then 0 else (CCIprice – Average(CCIprice, CCIlength)) / linDev / 0.015;

def CCI142 = CCI(CCIlength,(period = agg2));
def CCI145 = CCI(CCIlength,(period = agg5));

Marked as spam
Posted by (Questions: 5, Answers: 9)
Asked on June 16, 2020 1:12 am
137 views
0

I moved your question out of the Strategy Guide topic and into the Chart Studies topic because nothing in your question pertains to chart strategies.

When referencing higher time frames for the CCI there is only one way to get there:

```input timeFrameOne = AggregationPeriod.DAY; input length = 14; def price = close(period = timeFrameOne) + low(period = timeFrameOne) + high(period = timeFrameOne); def linDev = lindev(price, length); plot CCI = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;```

I am curious to know where you got the idea that it could be done using this method:

`def CCI142 = CCI(CCIlength,(period = agg2));`

That is completely invalid. Why should you know this? Because the CCI chart study takes a total of four input parameters and none of them are named "period". The input parameters used for referencing the CCI chart study are as follows:

CCI(length, over_sold, over_bought, showBreakoutSignals)

Those are the exact input parameters listed on the very top of the CCI chart study included with Thinkorswim. Notice there is nothing in there that says "period". And if you study the instructions provided by Thinkorswim you will find that secondary aggregation periods are only applied to fundamental data objects (such as open, high, low, close, etc...). They are not ever applied as an input parameter to ta built in chart study. Details here: