• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

Converting Indicator To Multi-TimeFrame (MTF) In ThinkOrSwim

tibby42

New member
Darn it all.. that takes away the usefulness for me because of repaint.. although I suppose 1/2 hr till close it might be ok. Thanks
 

Mac Trader

New member
Multi Time Frame Stochastics
Need help adding aggregated time period to standard TOS slow stochastics. Not great at coding can someone help please?
 
Last edited by a moderator:

Mac Trader

New member
I'm having trouble trying figure out why my indicator doesn't fit into overbought/oversold like the indicator in the other image.
Can someone help me out? Script is below, I basically added some code to standard TOS slow Stochastics indicator. Also from the image is there a way that I can smooth out the lines? @MerryDay


declare lower;

input agg = AggregationPeriod.FOUR_DAYS;
input over_bought = 80;
input over_sold = 20;
input Zeroline = 50;
input KPeriod = 12;
input DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};

plot SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
plot SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
plot OverBought = over_bought;
plot OverSold = over_sold;
plot zerobase = zeroline;

def upK = SlowK crosses above OverSold;
def upD = SlowD crosses above OverSold;
def downK = SlowK crosses below OverBought;
def downD = SlowD crosses below OverBought;

plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
UpSignal = Double.NaN;
DownSignal = Double.NaN;
case "On SlowK":
UpSignal = if upK then OverSold else Double.NaN;
DownSignal = if downK then OverBought else Double.NaN;
case "On SlowD":
UpSignal = if upD then OverSold else Double.NaN;
DownSignal = if downD then OverBought else Double.NaN;
case "On SlowK & SlowD":
UpSignal = if upK or upD then OverSold else Double.NaN;
DownSignal = if downK or downD then OverBought else Double.NaN;
}

UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");

SlowK.setDefaultColor(GetColor(5));
SlowD.setDefaultColor(GetColor(0));

OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
 
Last edited:

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
I'm having trouble trying figure out why my indicator doesn't fit into overbought/oversold like the indicator in the other image.
Can someone help me out? Script is below, I basically added some code to standard TOS slow Stochastics indicator. Also from the image is there a way that I can smooth out the lines? @MerryDay
The jagged jerky lines are built-into MTF indicators. Flat lines are due the the delay between the close of the previous candle and the next candle on the higher aggregation. The candle finally closes, it re-writes the final placement of the flat line and jags up to flat-lining the next candle.
 

hedge_mate

New member
Hello, Im trying to get some guidance/assistance in adjusting a code so that I can choose what timeframe aggregate a study from while viewing it on a different timeframe. For example, I want to be able to see the study aggregating from the D timeframe while looking at a lower timeframe chart. As you can see, ive gotten as far as to add the input, but im not too educated in code so dont know much beyond this. Here is the code below:

#Define the desired aggregation
input timeframe = AggregationPeriod.DAY;

DefineGlobalColor("Loose", Color.DARK_GRAY);
DefineGlobalColor("Regular", Color.RED);
DefineGlobalColor("Tight", Color.YELLOW);

def bbu = reference BollingerBands().UpperBand;
def bbl = BollingerBands().LowerBand;
def kc1u = KeltnerChannels(factor = 1.0).Upper_Band;
def kc1l = KeltnerChannels(factor = 1.0).Lower_Band;
def kc2u = KeltnerChannels(factor = 1.5).Upper_Band;
def kc2l = KeltnerChannels(factor = 1.5).Lower_Band;
def kc3u = KeltnerChannels(factor = 2.0).Upper_Band;
def kc3l = KeltnerChannels(factor = 2.0).Lower_Band;

# Loose squeeze
def cloudBUSqz3 = if bbu < kc3u then bbu else Double.NaN;
def cloudKC2USqz3 = if bbu < kc3u then kc3u else Double.NaN;
def cloudBLSqz3 = if bbl > kc3l then bbl else Double.NaN;
def cloudKC2LSqz3 = if bbl > kc3l then kc3l else Double.NaN;

AddCloud(cloudBUSqz3, cloudKC2USqz3, GlobalColor("Loose"), GlobalColor("Loose"), showBorder = yes);
AddCloud(cloudBLSqz3, cloudKC2LSqz3, GlobalColor("Loose"), GlobalColor("Loose"), showBorder = yes);
AddCloud(cloudBUSqz3, cloudKC2USqz3, GlobalColor("Loose"), GlobalColor("Loose"), showBorder = yes);
AddCloud(cloudBLSqz3, cloudKC2LSqz3, GlobalColor("Loose"), GlobalColor("Loose"), showBorder = yes);

# normal squeeze
def cloudBUSqz2 = if bbu < kc2u then bbu else Double.NaN;
def cloudKC2USqz2 = if bbu < kc2u then kc2u else Double.NaN;
def cloudBLSqz2 = if bbl > kc2l then bbl else Double.NaN;
def cloudKC2LSqz2 = if bbl > kc2l then kc2l else Double.NaN;

AddCloud(cloudBUSqz2, cloudKC2USqz2, GlobalColor("Regular"), GlobalColor("Regular"), showBorder = yes);
AddCloud(cloudBLSqz2, cloudKC2LSqz2, GlobalColor("Regular"), GlobalColor("Regular"), showBorder = yes);
AddCloud(cloudBUSqz2, cloudKC2USqz2, GlobalColor("Regular"), GlobalColor("Regular"), showBorder = yes);
AddCloud(cloudBLSqz2, cloudKC2LSqz2, GlobalColor("Regular"), GlobalColor("Regular"), showBorder = yes);

# tightest squeeze
def cloudBUSqz1 = if bbu < kc1u then bbu else Double.NaN;
def cloudKC2USqz1 = if bbu < kc1u then kc1u else Double.NaN;
def cloudBLSqz1 = if bbl > kc1l then bbl else Double.NaN;
def cloudKC2LSqz1 = if bbl > kc1l then kc1l else Double.NaN;

AddCloud(cloudBUSqz1, cloudKC2USqz1, GlobalColor("Tight"), GlobalColor("Tight"), showBorder = yes);
AddCloud(cloudBLSqz1, cloudKC2LSqz1, GlobalColor("Tight"), GlobalColor("Tight"), showBorder = yes);
AddCloud(cloudBUSqz1, cloudKC2USqz1, GlobalColor("Tight"), GlobalColor("Tight"), showBorder = yes);
AddCloud(cloudBLSqz1, cloudKC2LSqz1, GlobalColor("Tight"), GlobalColor("Tight"), showBorder = yes);
 

Guille

New member
The jagged jerky lines are built-into MTF indicators. Flat lines are due the the delay between the close of the previous candle and the next candle on the higher aggregation. The candle finally closes, it re-writes the final placement of the flat line and jags up to flat-lining the next candle.
Is there a way to add some sort of "Enable approximation" modifier to get a smoother line from the higher time frame charts on to the smaller time frame charts?
 

Similar threads

Top