#Tillson T3 Moving Average MTF Edition for ThinkOrSwim
#@diazlaz 2020.03.31 Version 1.0
#
# filename: Tillson_T3_Moving_Average
# source: https://futures.io/thinkorswim/34287-tilson-t3-moving-average.html#post460861
# created by: rmejia
# last update: 12/17/2014
# MTF Version @diazlaz 2020.03.31 Version 1.0
#hint:<b>T3 Adaptive Smoothing Indicator</b>\nThis study was adopted from the Technical Analysis of Stocks and Commodities article "Smoothing Techniques for More Accurate Signals" by Tim Tillson, Jan 1998 (V16:1 pp33-37)
#hint: indicator: Defines the level of filtering to occur, default is 3
#hint: volumeFactor: Adjusts the amplitude of the feedback added back into the base filter
input indicator = { T1, T2, default T3, T4, T5, T6 };
input price = close;
input period = 15;
input volumeFactor = 0.70;
input displace = 0;
input sign = { plus, default minus };
input Label = Yes;
input paintbars = Yes; #paints Primary aggregation1
input aggregation1 = AggregationPeriod.MIN;
input aggregation2 = AggregationPeriod.FIVE_MIN;
#aggregation1
#T1
def t1_price_01 = close(period = aggregation1);
def t1_ema_01 = ExpAverage( t1_price_01, period );
def t1_gd_01 = ( t1_ema_01 * ( 1 + volumeFactor ) ) - ( ExpAverage( t1_ema_01, period ) * volumeFactor );
#T2
def t2_price_01 = t1_gd_01;
def t2_ema_01 = ExpAverage( t2_price_01, period );
def t2_gd_01 = ( t2_ema_01 * ( 1 + volumeFactor ) ) - ( ExpAverage( t2_ema_01, period ) * volumeFactor );
#T3
def t3_price_01 = t2_gd_01;
def t3_ema_01 = ExpAverage( t3_price_01, period );
def t3_gd_01 = ( t3_ema_01 * ( 1 + volumeFactor ) ) - ( ExpAverage( t3_ema_01, period ) * volumeFactor );
#T4
def T4_price_01 = t3_gd_01;
def T4_ema_01 = ExpAverage( T4_price_01, period );
def T4_gd_01 = ( T4_ema_01 * ( 1 + volumeFactor ) ) - ( ExpAverage( T4_ema_01, period ) * volumeFactor );
#T5
def T5_price_01 = T4_gd_01;
def T5_ema_01 = ExpAverage( T5_price_01, period );
def T5_gd_01 = ( T5_ema_01 * ( 1 + volumeFactor ) ) - ( ExpAverage( T5_ema_01, period ) * volumeFactor );
#T6
def T6_price_01 = T5_gd_01;
def T6_ema_01 = ExpAverage( T6_price_01, period );
def T6_gd_01 = ( T6_ema_01 * ( 1 + volumeFactor ) ) - ( ExpAverage( T6_ema_01, period ) * volumeFactor );
plot T3_01;
switch( indicator ) {
case T1:
T3_01 = t1_gd_01;
case T2:
T3_01 = t2_gd_01;
case T3:
T3_01 = t3_gd_01;
case T4:
T3_01 = t4_gd_01;
case T5:
T3_01 = t5_gd_01;
case T6:
T3_01 = t6_gd_01;
}
T3_01.AssignValueColor(if T3_01 > T3_01[1] then Color.GREEN else Color.RED);
T3_01.HideBubble();
AddLabel(Label, if T3_01 > T3_01[1] then " A " else " A ", if T3_01 > T3_01[1] then Color.GREEN else Color.RED);
assignPriceColor(if paintbars and T3_01 < T3_01[1] then color.DARK_RED else if paintbars and T3_01 > T3_01[1] then color.DARK_GREEN else color.CURRENT);
#aggregation2
#T1
def t1_price_02 = close(period = aggregation2);
def t1_ema_02 = ExpAverage( t1_price_02, period );
def t1_gd_02 = ( t1_ema_02 * ( 1 + volumeFactor ) ) - ( ExpAverage( t1_ema_02, period ) * volumeFactor );
#T2
def t2_price_02 = t1_gd_02;
def t2_ema_02 = ExpAverage( t2_price_02, period );
def t2_gd_02 = ( t2_ema_02 * ( 1 + volumeFactor ) ) - ( ExpAverage( t2_ema_02, period ) * volumeFactor );
#T3
def t3_price_02 = t2_gd_02;
def t3_ema_02 = ExpAverage( t3_price_02, period );
def t3_gd_02 = ( t3_ema_02 * ( 1 + volumeFactor ) ) - ( ExpAverage( t3_ema_02, period ) * volumeFactor );
#T4
def T4_price_02 = t3_gd_02;
def T4_ema_02 = ExpAverage( T4_price_02, period );
def T4_gd_02 = ( T4_ema_02 * ( 1 + volumeFactor ) ) - ( ExpAverage( T4_ema_02, period ) * volumeFactor );
#T5
def T5_price_02 = T4_gd_02;
def T5_ema_02 = ExpAverage( T5_price_02, period );
def T5_gd_02 = ( T5_ema_02 * ( 1 + volumeFactor ) ) - ( ExpAverage( T5_ema_02, period ) * volumeFactor );
#T6
def T6_price_02 = T5_gd_02;
def T6_ema_02 = ExpAverage( T6_price_02, period );
def T6_gd_02 = ( T6_ema_02 * ( 1 + volumeFactor ) ) - ( ExpAverage( T6_ema_02, period ) * volumeFactor );
plot T3_02;
switch( indicator ) {
case T1:
T3_02 = t1_gd_02;
case T2:
T3_02 = t2_gd_02;
case T3:
T3_02 = t3_gd_02;
case T4:
T3_02 = t4_gd_02;
case T5:
T3_02 = t5_gd_02;
case T6:
T3_02 = t6_gd_02;
}
T3_02.AssignValueColor(if T3_02 > T3_02[1] then Color.GREEN else Color.RED);
T3_02.setLineWeight(2);
T3_02.HideBubble();
AddLabel(Label, if T3_02 > T3_02[1] then " B " else " B ", if T3_02 > T3_02[1] then Color.GREEN else Color.RED);
#End of #Tillson T3 Moving Average MTF Edition for ThinkOrSwim