Stochastic / EMA crossover Strategy For ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
A poster asked for an 'example' of a combined strategy using Stochastic and EMA. I googled the combination and found this:
https://www.tradingpedia.com/forex-trading-strategies/combining-stochastic-oscillator-and-emas/
I translated that site's strategy into the following script.

CAVEAT: I haven't used this strategy. I am posting it as an 'example' of a combined strategy. I strongly advocate looking at fundamentals, long term trend lines, and current news on an equity before entering a trade. If trading this strategy I would suggest adding a cycle and/or market strength indicator and support and resistance lines to your charts.

When copying this script MAKE SURE you save it as a STRATEGY (the tab next to Study)
tDQzFxy.png

Ruby:
# An Example Of A Stochastic and EMA Combined Strategy
# @MerryDay 5/21

def BuyCriteria =
#Go long when the 2-period EMA crosses above the 4-period EMA
MovAvgExponential("length" = 2)."AvgExp"[1] crosses above  MovAvgExponential("length" = 4)."AvgExp"[1] and
#AND continues higher:
MovAvgExponential("length" = 2)."AvgExp" is greater than
MovAvgExponential("length" = 2)."AvgExp"[1] and
#WHILE the stochastic is below 50.
reference StochasticFull().FullD is less than 50 ;

def SellCriteria =
#Sell if EMAs cross back:
MovAvgExponential("length" = 2)."AvgExp" crosses below
MovAvgExponential("length" = 4)."AvgExp" OR
#OR Sell if stochastic enters the overbought or oversold areas
reference StochasticFull().FullD is less than 20 or
reference StochasticFull().FullD is greater than 80 ;

# ########################################################
#Order Management
AddOrder(OrderType.BUY_AUTO, BuyCriteria, tickcolor = Color.yellow, arrowcolor = Color.black, name = "Buy", tradeSize = 100);
AddOrder(OrderType.SELL_TO_CLOSE, SellCriteria , tickcolor = Color.pink, arrowcolor = Color.red, name = "sell", tradeSize = 100);
# ########################################################
HERE IS A STUDY VERSION OF THE ABOVE STRATEGY
Ruby:
# An Example Of A Stochastic and EMA Combined Strategy
# @MerryDay 5/21
# ########################################################
# TOS Moving Averages
plot avg1 = MovingAverage(AverageType.eXPONENTIAL, close, 2);
plot avg2 = MovingAverage(AverageType.eXPONENTIAL, close, 4);
AddCloud(avg1, avg2, Color.light_green, Color.pink);
# ########################################################

def BuyCriteria =
#Go long when the 2-period EMA crosses above the 4-period EMA
MovAvgExponential("length" = 2)."AvgExp"[1] crosses above MovAvgExponential("length" = 4)."AvgExp"[1] and
#AND continues higher:
MovAvgExponential("length" = 2)."AvgExp" is greater than
MovAvgExponential("length" = 2)."AvgExp"[1] and
#WHILE the stochastic is below 50.
reference StochasticFull().FullD is less than 50 ;

def SellCriteria =
#Sell if EMAs cross back:
MovAvgExponential("length" = 2)."AvgExp" crosses below
MovAvgExponential("length" = 4)."AvgExp" OR
#OR Sell if stochastic enters the overbought or oversold areas
reference StochasticFull().FullD is less than 20 or
reference StochasticFull().FullD is greater than 80 ;

# ########################################################
Plot BuyTrigger = if BuyCriteria then low else double.NaN ;
BuyTrigger.SetPaintingStrategy(PaintingStrategy.ARROW_up);
BuyTrigger.SetLineWeight(2);
BuyTrigger.SetDefaultColor(color.dark_green) ;

Plot SellTrigger = if SellCriteria then high else double.NaN ;
SellTrigger.SetPaintingStrategy(PaintingStrategy.ARROW_down);
SellTrigger.SetLineWeight(2);
SellTrigger.SetDefaultColor(color.dark_red) ;
 
Last edited:

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

That chart on 4h shows beautiful enter & exit points
A poster asked for an 'example' of a combined strategy using Stochastic and EMA. I googled the combination and found this:
https://www.tradingpedia.com/forex-trading-strategies/combining-stochastic-oscillator-and-emas/
I translated that site's strategy into the following script.

CAVEAT: I haven't used this study. I am posting it as an 'example' of a combined strategy. I strongly advocate looking at fundamentals, long term trend lines, and current news on an equity before entering a trade. If trading this strategy I would suggest adding a cycle and/or market strength indicator and support and resistance lines to your charts.
IRTRtE6.png

Ruby:
# An Example Of A Stochastic and EMA Combined Strategy
# @MerryDay 5/21

def BuyCriteria =
#Go long when the 2-period EMA crosses above the 4-period EMA
        MovAvgExponential("length" = 2)."AvgExp"[1] crosses above
        MovAvgExponential("length" = 4)."AvgExp"[1] and
#AND continues higher:
       MovAvgExponential("length" = 2)."AvgExp" is greater than
       MovAvgExponential("length" = 2)."AvgExp"[1] and
#WHILE the stochastic is below 50.
       StochasticSlow("k period" = 5, "d period" = 3)."SlowD" is less than 50 ;

def SellCriteria =
#Sell if EMAs cross back:
     MovAvgExponential("length" = 2)."AvgExp" crosses below
     MovAvgExponential("length" = 2)."AvgExp" OR
#OR Sell if stochastic enters the overbought or oversold areas
    StochasticSlow("k period" = 5, "d period" = 3)."SlowD" is less than 20 or
    StochasticSlow("k period" = 5, "d period" = 3)."SlowD" is greater than 80 ;

# ########################################################
#Order Management
AddOrder(OrderType.BUY_AUTO, BuyCriteria, tickcolor = Color.yellow, arrowcolor = Color.black, name = "Buy", tradeSize = 100);
AddOrder(OrderType.SELL_TO_CLOSE, SellCriteria , tickcolor = Color.pink, arrowcolor = Color.red, name = "sell", tradeSize = 100);
# ########################################################







[/CODE
[/QUOTE]
 
A poster asked for an 'example' of a combined strategy using Stochastic and EMA. I googled the combination and found this:
https://www.tradingpedia.com/forex-trading-strategies/combining-stochastic-oscillator-and-emas/
I translated that site's strategy into the following script.

CAVEAT: I haven't used this study. I am posting it as an 'example' of a combined strategy. I strongly advocate looking at fundamentals, long term trend lines, and current news on an equity before entering a trade. If trading this strategy I would suggest adding a cycle and/or market strength indicator and support and resistance lines to your charts.
IRTRtE6.png

Ruby:
# An Example Of A Stochastic and EMA Combined Strategy
# @MerryDay 5/21

def BuyCriteria =
#Go long when the 2-period EMA crosses above the 4-period EMA
        MovAvgExponential("length" = 2)."AvgExp"[1] crosses above
        MovAvgExponential("length" = 4)."AvgExp"[1] and
#AND continues higher:
       MovAvgExponential("length" = 2)."AvgExp" is greater than
       MovAvgExponential("length" = 2)."AvgExp"[1] and
#WHILE the stochastic is below 50.
       StochasticSlow("k period" = 5, "d period" = 3)."SlowD" is less than 50 ;

def SellCriteria =
#Sell if EMAs cross back:
     MovAvgExponential("length" = 2)."AvgExp" crosses below
     MovAvgExponential("length" = 2)."AvgExp" OR
#OR Sell if stochastic enters the overbought or oversold areas
    StochasticSlow("k period" = 5, "d period" = 3)."SlowD" is less than 20 or
    StochasticSlow("k period" = 5, "d period" = 3)."SlowD" is greater than 80 ;

# ########################################################
#Order Management
AddOrder(OrderType.BUY_AUTO, BuyCriteria, tickcolor = Color.yellow, arrowcolor = Color.black, name = "Buy", tradeSize = 100);
AddOrder(OrderType.SELL_TO_CLOSE, SellCriteria , tickcolor = Color.pink, arrowcolor = Color.red, name = "sell", tradeSize = 100);
# ########################################################
Doesn't seem to work?? What time frame is needed?
 
I am 79 and so much of what you and others do here is way over my head . I would just like to thank you and the others here for all your hard work to help others like myself .
 
Last edited by a moderator:
A poster asked for an 'example' of a combined strategy using Stochastic and EMA. I googled the combination and found this:
https://www.tradingpedia.com/forex-trading-strategies/combining-stochastic-oscillator-and-emas/
I translated that site's strategy into the following script.

CAVEAT: I haven't used this strategy. I am posting it as an 'example' of a combined strategy. I strongly advocate looking at fundamentals, long term trend lines, and current news on an equity before entering a trade. If trading this strategy I would suggest adding a cycle and/or market strength indicator and support and resistance lines to your charts.

When copying this script MAKE SURE you save it as a STRATEGY (the tab next to Study)
tDQzFxy.png

Ruby:
# An Example Of A Stochastic and EMA Combined Strategy
# @MerryDay 5/21

def BuyCriteria =
#Go long when the 2-period EMA crosses above the 4-period EMA
MovAvgExponential("length" = 2)."AvgExp"[1] crosses above  MovAvgExponential("length" = 4)."AvgExp"[1] and
#AND continues higher:
MovAvgExponential("length" = 2)."AvgExp" is greater than
MovAvgExponential("length" = 2)."AvgExp"[1] and
#WHILE the stochastic is below 50.
reference StochasticFull().FullD is less than 50 ;

def SellCriteria =
#Sell if EMAs cross back:
MovAvgExponential("length" = 2)."AvgExp" crosses below
MovAvgExponential("length" = 4)."AvgExp" OR
#OR Sell if stochastic enters the overbought or oversold areas
reference StochasticFull().FullD is less than 20 or
reference StochasticFull().FullD is greater than 80 ;

# ########################################################
#Order Management
AddOrder(OrderType.BUY_AUTO, BuyCriteria, tickcolor = Color.yellow, arrowcolor = Color.black, name = "Buy", tradeSize = 100);
AddOrder(OrderType.SELL_TO_CLOSE, SellCriteria , tickcolor = Color.pink, arrowcolor = Color.red, name = "sell", tradeSize = 100);
# ########################################################
That’s cool! I’ll have to check this out
 
Doesn't seem to work?? What time frame is needed?
can someone assist me as to how to add alerts and sounds to this?

i too have concerns that this script is working,i havent heard a peep out of it and im running for 8 different stocks
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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