Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Code For 2 Custom Indicators I have Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
seankozak77
Posted : Thursday, January 5, 2012 11:26:30 AM
Registered User
Joined: 9/9/2011
Posts: 4
Hi there, My name is Sean Kozak and I have been using TC2000 since august. I Use interactive brokers as my brokerage platform and I currently trade stocks options and futures. I have some specific questions I am hoping you are able to answer for me.I am a student of Online Trading Academy and I have 2 custom code built indicators that i want to use in TC2000. The first indicator is a Bollinger Band Pierce indicator and it consists of 1 normal 2 std. dev. /20 ema Bollinger band with a 2nd bollinger band representing a 1% pierce of the band based on current price and the normal bollinger band. I currently use this in Think or swim as they recognize the ode i have built however I want to limit the number of platforms i work from down to tc2000 and IB.Here is the code for the bollinger band pierce indicator i would like to have built in TC2000.input price = close;input displace = 0;input length = 20;input Num_Dev_Dn = -2.0;input Num_Dev_up = 2.0;input pct_pierce = 1.0000; def sDev = stdev(data = price[-displace], length = length); plot MidLine = ExpAverage(data = price[-displace], length = length);plot LowerBand = MidLine + num_Dev_Dn * sDev;plot UpperBand = MidLine + num_Dev_Up * sDev;plot LowRiskLong = midline + (upperBand - midLine)/4;plot LowRiskShort = midline - (midline - lowerBand)/4;plot UpperPierce = upperband * (1 + pct_pierce/100);plot LowerPierce = lowerband * (1 - pct_pierce/100); LowerBand.SetDefaultColor(GetColor(0));MidLine.SetDefaultColor(GetColor(1)); UpperBand.SetDefaultColor(GetColor(5));The second indicator i would like to have built is an implied volatility indicator that separates IV into 5 sections that determines whether IV is high or low in relation to its 52/w high and 52/w low historical volatility. I also use this indicator in Think or swim and would like to use it with you to illuminate using three different platforms to work from. here is the code for the implied volatility indicator:declare lower; input days = 252;input upperRange = 20;input midUpperRange = 40;input midLowerRange = 40;input lowerRange = 20; plot iv = round(impVolatility()*100);plot hv = round(historicalVolatility()*100);plot highIV = highest(iv, days);plot lowIV = lowest(hv, 252); def upperPct = upperRange/100;def midUpperPct = midUpperRange/100;def midLowerPct = midLowerRange/100;def lowerPct = lowerRange/100;def yearlyRange = highIV - lowIV; plot upperPlot = highIV - yearlyRange*upperPct;plot midUpperPlot = highIV - yearlyRange*midUpperPct;plot midLowerPlot = lowIV + yearlyRange*midLowerPct;plot lowerPlot = lowIV + yearlyRange*lowerPct; addCloud(highIV, upperPlot, color.GREEN);addCloud(lowIV, lowerPlot, color.RED);addcloud(midUpperPlot, midLowerPlot, color.Yellow); highIV.setDefaultColor(color.GREEN);lowIV.setDefaultColor(color.RED);upperPlot.setDefaultColor(color.GREEN);midUpperPlot.setDefaultColor(color.Black);midLowerPlot.setDefaultColor(color.Black);lowerPlot.setDefaultColor(color.RED);I hope this is descriptive enough as I truly like using your platform...I currently work in a trading lab with 6 other traders and we are wanting too use your TC2000 platform for scanning and hopefully these two indicators for our trading. Can someone please respond to me via email at (email address removed by moderator) if there is any further questions please let me know. if you need to call me my number is (phone number removed by moderator) in case you want a more clearer description.I will await a response from one of the trainers.Sincerely,Sean Kozak
seankozak77
Posted : Thursday, January 5, 2012 11:29:27 AM
Registered User
Joined: 9/9/2011
Posts: 4
After posting the code in the email above i realize it is very crowded so i will post each code for each indicator separately .This is the code for the Bollinger Band indicator.

input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input pct_pierce = 1.0000;
def sDev = stdev(data = price[-displace], length = length);
plot MidLine = ExpAverage(data = price[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
plot LowRiskLong = midline + (upperBand - midLine)/4;
plot LowRiskShort = midline - (midline - lowerBand)/4;
plot UpperPierce = upperband * (1 + pct_pierce/100);
plot LowerPierce = lowerband * (1 - pct_pierce/100);
LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
seankozak77
Posted : Thursday, January 5, 2012 11:30:24 AM
Registered User
Joined: 9/9/2011
Posts: 4
here is the code for the 5 section implied volatility.  

declare lower; 
input days = 252;
input upperRange = 20;
input midUpperRange = 40;
input midLowerRange = 40;
input lowerRange = 20;
plot iv = round(impVolatility()*100);
plot hv = round(historicalVolatility()*100);
plot highIV = highest(iv, days);
plot lowIV = lowest(hv, 252);
def upperPct = upperRange/100;
def midUpperPct = midUpperRange/100;
def midLowerPct = midLowerRange/100;
def lowerPct = lowerRange/100;
def yearlyRange = highIV - lowIV;
plot upperPlot = highIV - yearlyRange*upperPct;
plot midUpperPlot = highIV - yearlyRange*midUpperPct;
plot midLowerPlot = lowIV + yearlyRange*midLowerPct;
plot lowerPlot = lowIV + yearlyRange*lowerPct;
addCloud(highIV, upperPlot, color.GREEN);
addCloud(lowIV, lowerPlot, color.RED);
addcloud(midUpperPlot, midLowerPlot, color.Yellow);
highIV.setDefaultColor(color.GREEN);
lowIV.setDefaultColor(color.RED);
upperPlot.setDefaultColor(color.GREEN);
midUpperPlot.setDefaultColor(color.Black);
midLowerPlot.setDefaultColor(color.Black);
lowerPlot.setDefaultColor(color.RED);
Bruce_L
Posted : Thursday, January 5, 2012 12:10:53 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The first indicator can be re-created by adding two sets of Exponential Bollinger Bands to Price History along with one Custom PCF Channel Indicator. One Bollinger Band needs to have the following settings:

- Period: 20
- Std Dev: 2.00
- Average Type: Exponential
- Plot Center Line: Checked

The other Bollinger Band needs to have the following settings:

- Period: 20
- Std Dev: 0.50
- Average Type: Exponential
- Plot Center Line: Checked

The Custom PCF Channel Indicator needs to have the following settings:

- Period: 1
- Average Type: Simple
- Width Multiplier: 1
- Indicator Line Formula: XAVGC20 + .02 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 20)
- Channel Width Formula: .01 * XAVGC20 + 2 * SQR(ABS(C ^ 2 + C1 ^ 2 + C2 ^ 2 + C3 ^ 2 + C4 ^ 2 + C5 ^ 2 + C6 ^ 2 + C7 ^ 2 + C8 ^ 2 + C9 ^ 2 + C10 ^ 2 + C11 ^ 2 + C12 ^ 2 + C13 ^ 2 + C14 ^ 2 + C15 ^ 2 + C16 ^ 2 + C17 ^ 2 + C18 ^ 2 + C19 ^ 2 - 20 * AVGC20 ^ 2) / 20)

It is not possible to create the second indicator as it is not possible to create Implied Volatility in TC2000.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.