RSI Stochastic Strategy

3L10Ns

New member
I stumbled across a 10-15 minute RSI Stochastic strategy that was posted on Tradingview, I set it up and it appears to give some good entries.

10 min to 15 min (works best) RSI Stoch Strategy: https://www.tradingview.com/chart/EURUSD/g4plwjJq-10-min-to-15-min-works-best-RSI-Stoch-Strategy/

So I figured I would start trying convert the built-in Indicator in TOS, not getting consistent alerts when oversold / Overbought are crossed.

1. Anyone know if this has already been composed?
2. My Noob code to follow..
 
ThinkorSwim already provides you with their Stochastic Crossover indicator. Here is the code:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2009-2020
#

#wizard input: stochasticMode
#wizard text: crosses
#wizard input: crossingType
#wizard text: Inputs: k period:
#wizard input: KPeriod

input KPeriod = 14;
input stochasticMode = {default StochasticFast, StochasticSlow};
input crossingType = {default Overbought, Oversold};

def stochastic;
switch (stochasticMode) {
case StochasticFast:
    stochastic = StochasticFull(KPeriod = KPeriod, slowing_period = 1).FullK;
case StochasticSlow:
    stochastic = StochasticFull(KPeriod = KPeriod, slowing_period = 3).FullK;
}

plot signal;
switch (crossingType) {
case Overbought:
    signal = crosses(stochastic, 80, CrossingDirection.Above);
case Oversold:
    signal = crosses(stochastic, 20, CrossingDirection.Below);
}

signal.DefineColor("OverBought", GetColor(1));
signal.DefineColor("OverSold", GetColor(9));
signal.AssignValueColor(if crossingType == CrossingType.oversold then signal.color("oversold") else signal.color("overbought"));
signal.SetPaintingStrategy(if crossingType == CrossingType.Oversold
      then PaintingStrategy.BOOLEAN_ARROW_UP
      else PaintingStrategy.BOOLEAN_ARROW_DOWN);

You can start building on top of that.
 

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

I played with this strategy several months ago... Not sure if I have any code or notes kicking around but I know there are several YouTube videos on the subject... That was where I got my inspiration... 💡

Post what you have and we'll go from there... (y)
 
Rich (BB code):
#
# RSI_Stochastic_1min_Dev001
#

declare lower;

input RSI_length = 4;
input over_bought = 75;
input over_sold = 25;
input RSI_average_type = AverageType.WILDERS;
input RSI_price = close;
input KPeriod = 5;
input DPeriod = 3;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK & RSI_"};

def RSI = RSI(price = RSI_price, length = RSI_length, averageType = RSI_average_type);

plot FullK = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullK;
def FullD = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullD;
plot OverBought = over_bought;
plot RSI_ = RSI ;
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;
def downRSI = RSI_ crosses below OverBought;
def upRSI = RSI_ crosses above OverSold;

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 & RSI_":
    UpSignal = if upK and upRSI then OverSold else Double.NaN;
    DownSignal = if downK and downrsi 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);
 
ThinkorSwim already provides you with their Stochastic Crossover indicator. Here is the code:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2009-2020
#

#wizard input: stochasticMode
#wizard text: crosses
#wizard input: crossingType
#wizard text: Inputs: k period:
#wizard input: KPeriod

input KPeriod = 14;
input stochasticMode = {default StochasticFast, StochasticSlow};
input crossingType = {default Overbought, Oversold};

def stochastic;
switch (stochasticMode) {
case StochasticFast:
    stochastic = StochasticFull(KPeriod = KPeriod, slowing_period = 1).FullK;
case StochasticSlow:
    stochastic = StochasticFull(KPeriod = KPeriod, slowing_period = 3).FullK;
}

plot signal;
switch (crossingType) {
case Overbought:
    signal = crosses(stochastic, 80, CrossingDirection.Above);
case Oversold:
    signal = crosses(stochastic, 20, CrossingDirection.Below);
}

signal.DefineColor("OverBought", GetColor(1));
signal.DefineColor("OverSold", GetColor(9));
signal.AssignValueColor(if crossingType == CrossingType.oversold then signal.color("oversold") else signal.color("overbought"));
signal.SetPaintingStrategy(if crossingType == CrossingType.Oversold
      then PaintingStrategy.BOOLEAN_ARROW_UP
      else PaintingStrategy.BOOLEAN_ARROW_DOWN);

You can start building on top of that.


Hi @BenTen , building upon the code you shared, I tried displaying the metric 'FullK' as a column in my watchlist (ie.. Quotes sub-tab on MarketWatch tab on TOS), but the editor gives error that RSI( ) is a useless expression.
I am wondering if technical functions such as RSI( ) and StochasticFull( ) need to be invoked differently in a Watchlist (as compared to an equivalent code used in Charts).

def RSI_length = 14;
def over_bought = 80;
def over_sold = 20;
def RSI_average_type = AverageType.WILDERS;
def RSI_price = close;
def KPeriod = 14;
def DPeriod = 3;
def slowing_period = 1;
def averageType = AverageType.SIMPLE;
def RSI = RSI(price = RSI_price, length = RSI_length, averageType = RSI_average_type);
plot FullK = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullK;
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
533 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