UPDATED TOS TEMPLATES

Version:0.9 StartHTML:-1 EndHTML:-1 StartFragment:0000000111 EndFragment:0000006074

12:08 MS: SB Code W/ 50 line below:       # # Study: FW_SnapBack # # Adapted from ToS CCI and RSI_EMA studies, # and configured as used by David Elliott as of 1/7/09. # # Mostly copywrite thinkorswim, inc. (2007) # # Modifications by ToS User: davidinc (david135@pc3i.com) # If you find any problems please let me know and refer # to the version number and date. Thanks. # # Revision history: # Vers Date        Change Descripton # ---- ---------   ----------------- #  0.0 2009-01-06  Original #  0.1 2009-01-12  Updated RSI section with code provided by kmktroy. #  0.2 2009-01-12  Updated RSI section with code provided by Sidewinder747 # declare lower; declare all_for_one;  input smoothingType = 1;  def   over_bought   = 80; def   over_sold     = 20; def   priceH        = high; def   priceL        = low; def   priceC        = close;  def KPeriod_0211 =  2; def DPeriod_0211 = 1; def slowing_period_0211 = 1; def KPeriod_0232 =  2; def DPeriod_0232 = 3; def slowing_period_0232 = 2; def KPeriod_0533 =  5; def DPeriod_0533 = 3; def slowing_period_0533 = 3; def KPeriod_0835 =  8; def DPeriod_0835 = 3; def slowing_period_0835 = 5; def KPeriod_1735 = 17; def DPeriod_1735 = 3; def slowing_period_1735 = 5; def KPeriod_4832 = 48; def DPeriod_4832 = 3; def slowing_period_4832 = 2;  def c1_0211  = priceC - Lowest(priceL, KPeriod_0211); def c1_0232  = priceC - Lowest(priceL, KPeriod_0232); def c1_0533  = priceC - Lowest(priceL, KPeriod_0533); def c1_0835  = priceC - Lowest(priceL, KPeriod_0835); def c1_1735  = priceC - Lowest(priceL, KPeriod_1735); def c1_4832  = priceC - Lowest(priceL, KPeriod_4832);  def c2_0211 = Highest(priceH, KPeriod_0211) - Lowest(priceL, KPeriod_0211); def c2_0232 = Highest(priceH, KPeriod_0232) - Lowest(priceL, KPeriod_0232); def c2_0533 = Highest(priceH, KPeriod_0533) - Lowest(priceL, KPeriod_0533); def c2_0835 = Highest(priceH, KPeriod_0835) - Lowest(priceL, KPeriod_0835); def c2_1735 = Highest(priceH, KPeriod_1735) - Lowest(priceL, KPeriod_1735); def c2_4832 = Highest(priceH, KPeriod_4832) - Lowest(priceL, KPeriod_4832);  def FastK_0211 = c1_0211 /c2_0211 * 100; def FastK_0232 = c1_0232 /c2_0232 * 100; def FastK_0533 = c1_0533 /c2_0533 * 100; def FastK_0835 = c1_0835 /c2_0835 * 100; def FastK_1735 = c1_1735 /c2_1735 * 100; def FastK_4832 = c1_4832 /c2_4832 * 100;  plot FullK_4832; plot FullK_1735; plot FullK_0835; plot FullK_0533; plot FullK_0232; plot FullK_0211;  if smoothingType == 1 then { FullK_0211 = Average(FastK_0211, slowing_period_0211);   FullK_0232 = Average(FastK_0232, slowing_period_0232);   FullK_0533 = Average(FastK_0533, slowing_period_0533);   FullK_0835 = Average(FastK_0835, slowing_period_0835);   FullK_1735 = Average(FastK_1735, slowing_period_1735);   FullK_4832 = Average(FastK_4832, slowing_period_4832); } else {   FullK_0211 = ExpAverage(FastK_0211, slowing_period_0211);   FullK_0232 = ExpAverage(FastK_0232, slowing_period_0232);   FullK_0533 = ExpAverage(FastK_0533, slowing_period_0533);   FullK_0835 = ExpAverage(FastK_0835, slowing_period_0835);   FullK_1735 = ExpAverage(FastK_1735, slowing_period_1735);   FullK_4832 = ExpAverage(FastK_4832, slowing_period_4832); }  FullK_0211.SetDefaultColor(Color.White); FullK_0211.SetStyle(Curve.Short_Dash); FullK_0232.SetDefaultColor(Color.White); FullK_0533.SetDefaultColor(Color.Yellow); FullK_0835.SetDefaultColor(Color.Green); FullK_1735.SetDefaultColor(Color.Red); FullK_4832.setDefaultColor(Color.Cyan);  FullK_0211.SetLineWeight(1); FullK_0232.SetLineWeight(1); FullK_0533.SetLineWeight(1); FullK_0835.SetLineWeight(1); FullK_1735.SetLineWeight(1); FullK_4832.SetLineWeight(1);   # RSI snapback studies - this piece is courtesy of Sidewinder747. Thanks. # updated 1/12/09.  input RSI_length = 2;  def diff = if close > close[1] then close - close[1] else 0; def diff2 = if close < close[1] then close[1] - close else 0;  rec avg = compoundValue(1, 2 / (RSI_length + 1) * diff + (RSI_length - 1) / (RSI_length + 1) * avg[1], diff * 2 / (RSI_length + 1)); rec avg2 = compoundValue(1, 2 / (RSI_length + 1) * diff2 + (RSI_length - 1) / (RSI_length + 1) * avg2[1], diff2 * 2 / (RSI_length + 1));  rec avgSMA = compoundValue(1, (avgSMA[1] + diff) / 2, diff); rec avgSMA2 = compoundValue(1, (avgSMA2[1] + diff2) / 2, diff2);  def value = if avg2 != 0 then 100 - 100 / (1 + avg / avg2) else 0; def valueSMA = if avg2 != 0 then 100 - 100 / (1 + avgSMA / avgSMA2) else 0;  plot RSI_EMA = ExpAverage(value, 2); plot RSI_SMA = Average(valueSMA, 2);  RSI_EMA.SetDefaultColor(Color.DARK_ORANGE); RSI_EMA.SetLineWeight(1); RSI_SMA.SetDefaultColor(Color.MAGENTA); RSI_SMA.SetLineWeight(1);  plot Zeroline = 50;Zeroline.setdefaultColor (color.GREEN);zeroline.setStyle (curve.SHORT_DASH);

Leave a Reply