Johnny Cash
Member
Could anyone tell me how to plot the Stochastic Oscillator on multiple timeframes? Both daily and weekly slow stochastic on the same chart.
# Stochastic Full MTF
# blt
# 7.15.2016
# 07.15.2016 blt v0, initial release
# 07.15.2016 blt v1, added on/off input for bubbles
# Here is a Stochastic Full_MTF indicator coded with a similar look
# as the RSI_Laguerre_Time_MTF uses. On the 1min chart image of DAL,
# I have the Stochastic set to a fast seting of 10,3,1, using higher
# agg period of 2min for the Stochastic.
#
# I used TOS Stochastic Full because with it you can do all three
# flavors (full 10,10,3; fast 10,3,1; slow 10,10,1) just changing
# the inputs
#
# This is an enhanced version with inputs to show bubbles or not.
# If you want to see it in expansion to the right, then you need to
# increase your right expansion to approx 35. The bubbles were
# already moveable at the inputs m and z
declare lower;
input usehigheraggperiod = {default "Current", "Higher"};
# Current uses the current chart agg. So if you are on a 1min chart
# the indicator is based on 1min. If you select higher, then whatever
# agg you enter at the input will be what is used for the RSI. So
# if you are on a 1min chart and higher is set to 2min, then a 2min
# RSI and the entries and targets are 2min based.
input agg = AggregationPeriod.TWO_MIN;
input atrlength = 14;
input atrfactor = 3;
# Variables:
def o;
def h;
def l;
def c;
def error = usehigheraggperiod == usehigheraggperiod."Higher" and GetAggregationPeriod() > agg;
switch (usehigheraggperiod) {
case Current:
o = (open + close[1]) / 2;
h = Max(high, close[1]);
l = Min(low, close[1]);
c = (o + h + l + close) / 4;
case Higher:
if error {
o = Double.NaN;
h = Double.NaN;
l = Double.NaN;
c = Double.NaN;
} else {
o = (open(period = agg) + close(period = agg)[1]) / 2;
h = Max(high(period = agg) , close(period = agg)[1]);
l = Min(low(period = agg) , close(period = agg)[1]);
c = ((open(period = agg) + close(period = agg)[1]) / 2
+ Max(high(period = agg), close(period = agg)[1])
+ Min(low(period = agg) , close(period = agg)[1])
+ close(period = agg)) / 4;
}
}
AddLabel(error, "Chart Aggregation Period is greater than RSI aggregation period. Need to Change input to a higher agg than current chart aggregation or choose 'Current' at input usehigheraggperiod", Color.WHITE);
#TOS StochasticFull
#used TOS StochasticFull because with it you can do all 3 (full 10,10,3; fast 10,3,1; slow 10,10,1) with it by just changing the inputs for kperiod
input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
def priceH = h;
def priceL = l;
def priceC = c;
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0
then c1 / c2 * 100
else 0;
plot FullK = if isnan(close) then double.nan else MovingAverage(averageType, FastK, slowing_period);
plot FullD = if isnan(close) then double.nan else MovingAverage(averageType, FullK, DPeriod);
plot OverBought = if isnan(close) then double.nan else over_bought;
plot OverSold = if isnan(close) then double.nan else over_sold;
FullK.SetDefaultColor(GetColor(5));
FullD.SetDefaultColor(GetColor(0));
OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
def ob = over_bought;
def os = over_sold;
def stou = if FullK crosses above ob or
FullK crosses above os
then 1
else if stou[1] == 1 and !(FullK crosses below ob) and FullK > os
then 1
else 0;
FullK.AssignValueColor(if stou
then Color.GREEN
else Color.RED);
input usealerts = no;
Alert(usealerts and FullK crosses below OverBought, "", Alert.BAR, Sound.Bell);
Alert(usealerts and FullK crosses above OverSold, "", Alert.BAR, Sound.Bell);
AddCloud(if FullK >= OverBought
then FullK
else Double.NaN,
OverBought,
Color.GREEN, Color.GREEN);
AddCloud(if FullK <= OverSold
then OverSold
else Double.NaN,
FullK,
Color.RED, Color.RED);
plot mid = if isnan(close) then double.nan else 50;
plot lineh = if isnan(close) then double.nan else 110;
plot linel = if isnan(close) then double.nan else -10;
lineh.setdefaultColor(color.gray);
linel.setdefaultColor(color.gray);
lineh.hidebubble();
linel.hidebubble();
AddLabel(yes, "STO (" + agg / 60000 + "min): " + Round(FullK, 0),
if FullK > 0
then if FullK[1] > FullK
then Color.DARK_GREEN
else Color.GREEN
else if FullK[1] < FullK
then Color.DARK_RED
else Color.RED);
def atr = Average(TrueRange(h, c, l), atrlength);
def entry = if FullK crosses above OverSold or stou[1] == 0 and FullK crosses above OverBought
then close
else if FullK crosses below OverBought or stou[1] and FullK crosses below OverSold
then close
else entry[1];
def ebar = if FullK crosses above OverSold or stou[1] == 0 and FullK crosses above OverBought
then BarNumber()
else if FullK crosses below OverBought or stou[1] and FullK crosses below OverSold
then BarNumber()
else Double.NaN;
def target = if FullK crosses above OverSold or stou[1] == 0 and FullK crosses above OverBought
then Round((close + (atrfactor * atr)) / TickSize(), 0) * TickSize()
else if FullK crosses below OverBought or stou[1] and FullK crosses below OverSold
then Round((close - (atrfactor * atr)) / TickSize(), 0) * TickSize()
else target[1];
def u_d = if FullK crosses above OverSold or stou[1] == 0 and FullK crosses above OverBought
then 1
else if FullK crosses below OverBought or stou[1] and FullK crosses below OverSold
then -1
else u_d[1];
def goalu = if u_d > 0 and high >= target
then 1
else if goalu[1] == 1 and u_d > 0
then 1
else 0;
def goald = if u_d < 0 and low <= target
then 1
else if goald[1] == 1 and u_d < 0
then 1
else 0;
AddLabel(1, if error then " "
else "T:"+(if u_d > 0 then "Up " else "Dn") + " " + AsText(target) +
(if u_d < 0
then if goald == 0
then " Need " + AsText(Round((target - close), 2))
else " Met "
else "") +
(if u_d > 0
then if goalu == 0
then " Need " + AsText(Round((target - close), 2))
else " Met "
else ""),
if u_d < 0 and !goald or u_d > 0 and !goalu
then Color.WHITE
else Color.GREEN);
input showentrybubble = yes;
input m = 2;
def m1 = m + 1;
AddChartBubble(showentrybubble and BarNumber() == HighestAll(ebar),
if FullK crosses above OverSold or stou[1] and FullK crosses below OverSold
then OverSold
else OverBought,
"Entry: " + AsText(Round(entry, 2)),
if u_d > 0
then Color.GREEN
else Color.RED,
if u_d > 0
then no
else yes);
input showtargetbubble = yes;
AddChartBubble(showtargetbubble and IsNaN(close[m]) and !IsNaN(close[m1]),
if Between(FullK[m1], OverSold, OverBought)
then FullK[m1]
else if u_d[m1] > 0
then 80
else 20,
if error[m1]
then " "
else "T:"+(if u_d[m1] > 0 then "Up " else "Dn ") + " " + AsText(target[m1]) +
(if u_d[m1] < 0 and !goald[m1]
then "\nDiff " + AsText(Round((target[m1] - close[m1]), 2))
else if u_d[m1] > 0 and !goalu[m1]
then "\nDiff " + AsText(Round((target[m1] - close[m1]), 2))
else " Met "),
if u_d[m1] < 0 and !goald[m1] or u_d[m1] > 0 and !goalu[m1]
then Color.WHITE
else Color.GREEN,
if Between(FullK[m1], OverSold, OverBought)
then if u_d[m1] < 0
then no
else yes
else if u_d[m1] < 0
then no
else yes);
#StochasticFull Bubble
input showstochasticbubble = yes;
input z = 30;#Hint z: = number of spaces to move the StochasticFull bubbles sideways
def z1 = z + 1;
AddChartBubble(showstochasticbubble and IsNaN(close[z]) and !IsNaN(close[z1]),
mid[z1],
"S",
if stou[z1]
then Color.GREEN
else Color.RED);
declare lower;
input over_bought = 80;
input over_sold = 20;
input aggregationPeriod = AggregationPeriod.DAY;
input KPeriod = 10;
input DPeriod = 10;
input slowing_period = 3;
plot FullK = Average((close(period = aggregationPeriod) - Lowest(low(period = aggregationperiod), KPeriod)) / (Highest(high(period = aggregationperiod), KPeriod) - Lowest(low(period = aggregationperiod), KPeriod)) * 100, slowing_period);
plot FullD = Average(Average((close(period = aggregationPeriod) - Lowest(low(period = aggregationperiod), KPeriod)) / (Highest(high(period = aggregationperiod), KPeriod) - Lowest(low(period = aggregationperiod), KPeriod)) * 100, slowing_period), DPeriod);
plot OverBought = over_bought;
plot OverSold = over_sold;
declare lower;
input over_bought = 80;
input over_sold = 32;
input KPeriod = 10;
input DPeriod = 3;
input aggp = AggregationPeriod.WEEK;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};
def dailywk;
if GetAggregationPeriod() < AggregationPeriod.WEEK {
dailywk = AggregationPeriod.WEEK;
} else {
dailywk = AggregationPeriod.DAY;
}
#def plwk = movingaverage(averagetype.simple,priceL,5);
#def phwk = movingaverage(averagetype.simple,priceH,5) ;
#def pcwk = movingaverage(averagetype.simple,priceC,5) ;
plot SlowK = reference StochasticFull(
over_bought = over_bought,
over_sold = over_sold,
KPeriod = KPeriod,
DPeriod = DPeriod,
priceH = high(period = dailywk),
priceL = low(period = dailywk),
priceC = close(period = dailywk),
slowing_period = 3).FullK
;
plot SlowD = reference StochasticFull(
over_bought = over_bought,
over_sold = over_sold,
KPeriod = KPeriod,
DPeriod = DPeriod,
priceH = high(period = dailywk),
priceL = low(period = dailywk),
priceC = close(period = dailywk),
slowing_period = 3).FullD
;
plot OverBought = over_bought;
plot OverSold = over_sold;
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);
I'm trying to create a weekly stochastic indicator that I can use on my daily chart, but the plot points don't seem to get smoothed like they do on the tradingview version of the indicator. Any thoughts how I could fix that? Here is the code I'm currently using.
ed out?Code:#Example Smooth Plot HigherAgg on LowerAgg #Usethinkscript request AnAirDrop #Sleepyz input show_original_plot = yes; input show_smooth_plot = yes; declare lower; input over_bought = 80; input over_sold = 32; input KPeriod = 10; input DPeriod = 3; input aggp = AggregationPeriod.WEEK; input priceH = high; input priceL = low; input priceC = close; input averageType = AverageType.SIMPLE; input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"}; def dailywk; if GetAggregationPeriod() < AggregationPeriod.WEEK { dailywk = AggregationPeriod.WEEK; } else { dailywk = AggregationPeriod.DAY; } #def plwk = movingaverage(averagetype.simple,priceL,5); #def phwk = movingaverage(averagetype.simple,priceH,5) ; #def pcwk = movingaverage(averagetype.simple,priceC,5) ; plot SlowK = reference StochasticFull( over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, DPeriod = DPeriod, priceH = high(period = dailywk), priceL = low(period = dailywk), priceC = close(period = dailywk), slowing_period = 3).FullK ; slowk.sethiding(show_original_plot == no); plot SlowD = reference StochasticFull( over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, DPeriod = DPeriod, priceH = high(period = dailywk), priceL = low(period = dailywk), priceC = close(period = dailywk), slowing_period = 3).FullD ; slowd.sethiding(show_original_plot == no); plot OverBought = over_bought; plot OverSold = over_sold; 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); #Smoothed Plots def minutes = aggp/60000; def bar = BarNumber(); def x = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0 then slowk else x[1]; def xx = (if x!=x[1] then xx[1] + 1 else xx[1]); def xxx = if xx!= xx[1] then x else Double.NaN; plot xsmooth =if !show_smooth_plot then double.nan else if isnan(close[-1]) then slowk else xxx; xsmooth.EnableApproximation(); def x1 = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0 then slowd else x1[1]; def xx1 = (if x1!=x1[1] then xx1[1] + 1 else xx[1]); def xxx1 = if xx1!= xx1[1] then x1 else Double.NaN; plot x1smooth = if !show_smooth_plot then double.nan else if isnan(close[-1]) then slowd else xxx1; x1smooth.EnableApproximation(); Any thoughts how I can get those plots smooth
#Example Smooth Plot HigherAgg on LowerAgg
#Usethinkscript request AnAirDrop
#Sleepyz
input show_original_plot = yes;
input show_smooth_plot = yes;
declare lower;
input over_bought = 80;
input over_sold = 32;
input KPeriod = 10;
input DPeriod = 3;
input aggp = AggregationPeriod.WEEK;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"};
def dailywk;
if GetAggregationPeriod() < AggregationPeriod.WEEK {
dailywk = AggregationPeriod.WEEK;
} else {
dailywk = AggregationPeriod.DAY;
}
#def plwk = movingaverage(averagetype.simple,priceL,5);
#def phwk = movingaverage(averagetype.simple,priceH,5) ;
#def pcwk = movingaverage(averagetype.simple,priceC,5) ;
plot SlowK = reference StochasticFull(
over_bought = over_bought,
over_sold = over_sold,
KPeriod = KPeriod,
DPeriod = DPeriod,
priceH = high(period = dailywk),
priceL = low(period = dailywk),
priceC = close(period = dailywk),
slowing_period = 3).FullK
;
slowk.sethiding(show_original_plot == no);
plot SlowD = reference StochasticFull(
over_bought = over_bought,
over_sold = over_sold,
KPeriod = KPeriod,
DPeriod = DPeriod,
priceH = high(period = dailywk),
priceL = low(period = dailywk),
priceC = close(period = dailywk),
slowing_period = 3).FullD
;
slowd.sethiding(show_original_plot == no);
plot OverBought = over_bought;
plot OverSold = over_sold;
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);
#Smoothed Plots
def minutes = aggp/60000;
def bar = BarNumber();
def x = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0
then slowk
else x[1];
def xx = (if x!=x[1] then xx[1] + 1 else xx[1]);
def xxx = if xx!= xx[1] then x else Double.NaN;
plot xsmooth =if !show_smooth_plot then double.nan else if isnan(close[-1]) then slowk else xxx;
xsmooth.EnableApproximation();
def x1 = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0
then slowd
else x1[1];
def xx1 = (if x1!=x1[1] then xx1[1] + 1 else xx[1]);
def xxx1 = if xx1!= xx1[1] then x1 else Double.NaN;
plot x1smooth = if !show_smooth_plot then double.nan else if isnan(close[-1]) then slowd else xxx1;
x1smooth.EnableApproximation();
Wow, that is awesome work, been looking for that for a long time.
Question: is it possible to get rid of the zig zag line( the original plot) when i set to "no" the all thing disappears.
Oops. thank you for the heads up. I fixed the code above in #13. I forgot that I needed those plot statements. Following is the corrected code:
Code:#Example Smooth Plot HigherAgg on LowerAgg #Usethinkscript request AnAirDrop #Sleepyz input show_original_plot = yes; input show_smooth_plot = yes; declare lower; input over_bought = 80; input over_sold = 32; input KPeriod = 10; input DPeriod = 3; input aggp = AggregationPeriod.WEEK; input priceH = high; input priceL = low; input priceC = close; input averageType = AverageType.SIMPLE; input showBreakoutSignals = {default "No", "On SlowK", "On SlowD", "On SlowK & SlowD"}; def dailywk; if GetAggregationPeriod() < AggregationPeriod.WEEK { dailywk = AggregationPeriod.WEEK; } else { dailywk = AggregationPeriod.DAY; } #def plwk = movingaverage(averagetype.simple,priceL,5); #def phwk = movingaverage(averagetype.simple,priceH,5) ; #def pcwk = movingaverage(averagetype.simple,priceC,5) ; plot SlowK = reference StochasticFull( over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, DPeriod = DPeriod, priceH = high(period = dailywk), priceL = low(period = dailywk), priceC = close(period = dailywk), slowing_period = 3).FullK ; slowk.sethiding(show_original_plot == no); plot SlowD = reference StochasticFull( over_bought = over_bought, over_sold = over_sold, KPeriod = KPeriod, DPeriod = DPeriod, priceH = high(period = dailywk), priceL = low(period = dailywk), priceC = close(period = dailywk), slowing_period = 3).FullD ; slowd.sethiding(show_original_plot == no); plot OverBought = over_bought; plot OverSold = over_sold; 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); #Smoothed Plots def minutes = aggp/60000; def bar = BarNumber(); def x = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0 then slowk else x[1]; def xx = (if x!=x[1] then xx[1] + 1 else xx[1]); def xxx = if xx!= xx[1] then x else Double.NaN; plot xsmooth =if !show_smooth_plot then double.nan else if isnan(close[-1]) then slowk else xxx; xsmooth.EnableApproximation(); def x1 = if bar == 1 or bar[1] % ((Ceil(minutes) ) / (GetAggregationPeriod() / 60000)) == 0 then slowd else x1[1]; def xx1 = (if x1!=x1[1] then xx1[1] + 1 else xx[1]); def xxx1 = if xx1!= xx1[1] then x1 else Double.NaN; plot x1smooth = if !show_smooth_plot then double.nan else if isnan(close[-1]) then slowd else xxx1; x1smooth.EnableApproximation();
Thank you for the kind remark.
I am looking for help to create a label that pulls data from a higher aggregation period. For example, I want to look at the daily chart and have a label that tells me if the StochasticSlow, SlowK is greater than the StochasticSlow, SlowK from the candle before on the weekly chart. I wrote the following code below but it only tells me the information from the current aggregation period that I am looking at and not the weekly. Any help would be greatly appreciated.
input firstAggregation = AggregationPeriod.WEEK;
def StochasticSlowUp;
if GetAggregationPeriod() <= firstAggregation
{
StochasticSlowUp = StochasticSlow("average type" = "EXPONENTIAL")."SlowK" is greater than StochasticSlow("average type" = "EXPONENTIAL")."SlowK" from 1 bars ago;
}
else {
StochasticSlowUp = 0;
}
addlabel(yes, StochasticSlowUp);
Ruby:input firstAggregation = AggregationPeriod.WEEK; Script stochslow { input agg = aggregationPeriod.WEEK; input over_bought = 80; input over_sold = 20; input KPeriod = 10; input DPeriod = 10; def priceH = high(period=agg); def priceL = low(period=agg); def priceC = close(period=agg); 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; } def StochasticSlowUp; if GetAggregationPeriod() <= firstAggregation { StochasticSlowUp = stochslow().SlowK from 1 bars ago; } else { StochasticSlowUp = 0; } addlabel(yes, StochasticSlowUp);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Mobius Full Stochastic MTF for ThinkorSwim | Indicators | 2 | ||
D | MTF Stochastic "Stoplight" Upper Study | Questions | 5 | |
R | MTF Automatic Fibonacci Retracement | Questions | 0 | |
S | MTF : Sequence Counter :TOS | Questions | 0 | |
P | Convert TradingView MTF Stochistic with divergence | Questions | 0 |