Overlaid Stochastics

greywaver

New member
Hi. I have combined two different settings stochastics into one window. Unfortunately, the scaling is off as
I now see two sets of 80/20 lines. How do I sync the scaling so each stochastic uses the exact same 80/20 lines?
Thanks!
 
Solution
Thanks to both. I'll check out the link.

You can use the script function to combine multiple versions of the same indicator. The following has 2 versions of stochasticfull indicator, but you can easily make more following the same process as in this code.


Capture.jpg
Ruby:
declare lower;
script stoch {
#
# TD Ameritrade IP Company, Inc. (c) 2008-2021
#
    input over_bought = 80;
    input over_sold = 20;
    input KPeriod = 10;
    input DPeriod = 10;
    input priceH = high;
    input priceL = low;
    input priceC = close;
    input slowing_period = 3;
    input averageType = AverageType.SIMPLE;
    input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};

    def lowest_k = Lowest(priceL...
The most precise way would be to combine the actual code into one indicator.
Combining the scripts would be one way. But they would still need to be scaled, in order to plot them together.
There is a "normalize" routine, that will sometimes allow them to be set to the same scale without skewing the data.
Read more here: https://usethinkscript.com/threads/how-to-combine-studies-indicators-in-thinkorswim.8766/

There could a much simpler fix however without seeing the code, no one will be able to assist further.
 
Last edited:
Thanks to both. I'll check out the link.

You can use the script function to combine multiple versions of the same indicator. The following has 2 versions of stochasticfull indicator, but you can easily make more following the same process as in this code.


Capture.jpg
Ruby:
declare lower;
script stoch {
#
# TD Ameritrade IP Company, Inc. (c) 2008-2021
#
    input over_bought = 80;
    input over_sold = 20;
    input KPeriod = 10;
    input DPeriod = 10;
    input priceH = high;
    input priceL = low;
    input priceC = close;
    input slowing_period = 3;
    input averageType = AverageType.SIMPLE;
    input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};

    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 = MovingAverage(averageType, FastK, slowing_period);
    plot FullD = MovingAverage(averageType, FullK, DPeriod);

    plot OverBought = over_bought;
    plot OverSold = over_sold;

    def upK = FullK crosses above OverSold;
    def upD = FullD crosses above OverSold;
    def downK = FullK crosses below OverBought;
    def downD = FullD crosses below OverBought;

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

    FullK.SetDefaultColor(GetColor(5));
    FullD.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);
}

input k1  = 10;
input d1  = 10;
input sp1 = 3;
input k2  = 20;
input d2  = 20;
input sp2 = 6;


plot stoch1 = stoch(kperiod = k1, dperiod = d1, slowingperiod = sp1);
plot stoch2 = stoch(kperiod = k2, dperiod = d2, slowingperiod = sp2);
stoch1.SetDefaultColor(Color.CYAN);
stoch2.SetDefaultColor(Color.WHITE);

plot OB  = 80;
plot OS  = 20;
plot Mid = 50;

#
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
344 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top