Slow Stochastic Price Chart Label?

Hopperious

New member
Is there a way to have the Slow Stochastic shown as a Label on the price chart instead of on the lower study as a line.

Code:
# Slow Smooth STOCHASTIC

input N2_Period = 9;
input R2_Period = 6;

def Ln2 = Lowest(low, N2_Period);
def Hn2 = Highest(high, N2_Period);
def Y2 = ((close - Ln2) / (Hn2 - Ln2)) * 100;
def X2 = ExpAverage(Y2, R2_Period);


def Lxn = Lowest(X2, N2_Period);
def Hxn = Highest(X2, N2_Period);
def DSS = ((X2 - Lxn) / (Hxn - Lxn)) * 100;


def DSSb = ExpAverage(DSS, R2_Period);
#DSSb.setdefaultColor(Color.YELLOW);

plot DSSsignal = DSSb[1];
DSSsignal.AssignValueColor(if DSSb > DSSsignal then Color.DARK_GREEN else Color.DARK_RED);
DSSsignal.SetLineWeight(3);

The Label "Slow Stoch" would turn dark_green when greater and dark_red when less as the DSSsignal.AssignValueColor shows above on the last line of the code - color would only change at the close of each bar
 
Last edited by a moderator:

timh

New member
Hello,

Can anyone convert the Stochastic Slow indicator from TradeStation to Thinkscrip or does anyone has that script already? I am trying to find one or edited it, with no luck.

Thanks in advance,
Tim
 

BenTen

Administrative
Staff member
Staff
VIP
@timh It's as easy as searching it in your ThinkorSwim

QzPvtie.png
 

rad14733

Well-known member
VIP
Yes, it is, but the numbers and setting is different between them, TS stochastic slow default setting is 14,3,3,1,20, TOS only has 10,10. Just couldn't find it anywhere, hopefully someone here has that script, thanks for your help.
Just change the settings to match and it should paint fairly close to the same as in TradeStation...
 

Johnny Cash

Member
VIP
Try this, may help
just change aggrationperiod

Code:
declare lower;

input over_bought = 80;
input sell_signal = 68;
input over_sold = 32;
input aggregationPeriod = AggregationPeriod.WEEK;
input KPeriod = 10;
input DPeriod = 3;
input slowing_period = 3;
#input slowk =10;
#input slowd = 3;
#input percentchg = close;
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 sellsignal = sell_signal;
plot OverSold = over_sold;

#plot close =  ((dperiod  / kperiod  )-1) * 100;
 

elreytrder

New member
2019 Donor
VIP
Hi Guys, I need help on my first post here. I've been looking for Stochastic upper label for awhile but nowhere to find one so I figured it out how to add upper label.

If anyone could help adjust the code, I'm trying to separate color of %K >or< 50%. I'm looking for %K > 50 then shows color green or blue (doesn't matter), and then if %K <50 then shows color red or orange. the only code I added from original StochasticFAST is at the bottom

Thanks guy, really appreciate it! Also, all lines still show on upper study if you can hide or remove them please do, if not I can unselect to not show on study later.


Code:
#
# Stochastic %K label
#

declare upper;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FastK", "On FastD", "On FastK & FastD"};

plot FastK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullK;
plot FastD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullD;
plot OverBought = over_bought;
plot OverSold = over_sold;

def upK = FastK crosses above OverSold;
def upD = FastD crosses above OverSold;
def downK = FastK crosses below OverBought;
def downD = FastD crosses below OverBought;

plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
    UpSignal = Double.NaN;
    DownSignal = Double.NaN;
case "On FastK":
    UpSignal = if upK then OverSold else Double.NaN;
    DownSignal = if downK then OverBought else Double.NaN;
case "On FastD":
    UpSignal = if upD then OverSold else Double.NaN;
    DownSignal = if downD then OverBought else Double.NaN;
case "On FastK & FastD":
    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");

FastK.SetDefaultColor(GetColor(5));
FastD.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);

AddLabel(yes, "%K= " + FastK, Color.BLUE);
 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
@elreytrder Here you go

Code:
#
# Stochastic %K label
#

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FastK", "On FastD", "On FastK & FastD"};

def FastK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullK;
def FastD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullD;
def OverBought = over_bought;
def OverSold = over_sold;

def upK = FastK crosses above OverSold;
def upD = FastD crosses above OverSold;
def downK = FastK crosses below OverBought;
def downD = FastD crosses below OverBought;

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

AddLabel(yes, Concat("FastK = ", FastK), if FastK > 50 then color.green else if FastK < 50 then color.red else color.gray);
 

MerryDay

Administrative
Staff member
Staff
VIP
@elreytrder Here is a more appreviated version of @BenTen's script
SQMnso6.png

Ruby:
#
# Stochastic %K label
#

declare upper;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;


def FastK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullK;
AddLabel(yes, "%K= " + round(FastK,2), if FastK > 50 then color.green else color.red);
FYI for future reference To share code in your post, click on this icon at the top of your post and then past the code.
QNUw9Yh.png

More Guidelines for When Asking For Help with A Study
HTH
 

elreytrder

New member
2019 Donor
VIP
@elreytrder Here you go

Code:
#
# Stochastic %K label
#

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FastK", "On FastD", "On FastK & FastD"};

def FastK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullK;
def FastD = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullD;
def OverBought = over_bought;
def OverSold = over_sold;

def upK = FastK crosses above OverSold;
def upD = FastD crosses above OverSold;
def downK = FastK crosses below OverBought;
def downD = FastD crosses below OverBought;

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

AddLabel(yes, Concat("FastK = ", FastK), if FastK > 50 then color.green else if FastK < 50 then color.red else color.gray);
Thank you Ben !
@elreytrder Here is a more appreviated version of @BenTen's script
SQMnso6.png

Ruby:
#
# Stochastic %K label
#

declare upper;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;


def FastK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 1, averageType).FullK;
AddLabel(yes, "%K= " + round(FastK,2), if FastK > 50 then color.green else color.red);
FYI for future reference To share code in your post, click on this icon at the top of your post and then past the code.
QNUw9Yh.png

More Guidelines for When Asking For Help with A Study
HTH
Thank you Guys! @BenTen @MerryDay
 

Similar threads

Top