Product Description
Letters To S&C by Technical Analysis, Inc.
CHOPPINESS INDEX CODE FOR THINKORSWIM
Editor,
I was going through the May 2012 article on the choppiness index (“Fractal Energies” by Doc Severson) and the code given for thinkorswim. I have copied & pasted the code from the article, but it’s giving me an error at the following line:
#Plot1(100 * Log(Summation (TrueRange,Len) / (Highest(C[1],Len)
- Lowest(C[1],Len)) / Log(Len)), "CI2");
Can you help?
John Parbhu
Author Doc Severson replies:
That instruction needs to be on one line for it to work correctly.
If you format that line of code so that it is entered in thinkorswim as one line, it will work fine. I will show the code listing again here, with the command in question highlighted in red, but keep in mind it is difficult to show the code listing correctly on the printed page with the formatting and line breaks that the printed page imposes.
# { CI: Choppiness Index }
declare lower;
# Inputs: Len(13);
input Len = 14;
input CIx = {default CI3, CI2};
#Plot1(100 * Log(Summation(TrueRange,Len)/(Highest(C[1],Len) - Lowest(C[1],Len))/Log(Len)), "CI2");
def CI2 = 100 * log( Sum( TrueRange(high,close,low),Len)
) / ( Highest(close[1],Len) - Lowest(close[1],Len))
/ log(Len);
def CI3 = ( ( log(Sum(TrueRange(high,close,low),Len) /
(
Highest(if high >= close[1] then high else
close[1],Len) -
Lowest( if low <= close[1] then low else close[1],Len)
)
) / log(10)
) / (log(Len)/log(10))
) * 100;
plot CI = if CIx == CIx.CI3 then CI3 else CI2;
CI.AssignValueColor( Color.Blue);
# Plot2(60,"60Li");
plot line60 = 60;
line60.AssignValueColor(Color.DARK_GREEN);
# Plot3(35,"35Li");
plot line35 = 35;
line35.AssignValueColor(Color.BLACK);
Editor: Subscribers will find this code listing at the Subscriber’s Area of our website.