Stochastic Moving Average

LucasVivien Updated   
Hi all,

This Strategy script combines the power of EMAs along with the Stochastic Oscillator in a trend following / continuation manner, along with some cool functionalities.
I designed this script especially for trading altcoins, but it works just as good on Bitcoin itself and on some Forex pairs.

______ SIGNALS ______

The script has 4 mandatory conditions to unlock a trading signal. Find these conditions for a long trade below (works the exact other way round for shorts)
- Fast EMA must be higher than Slow EMA
- Stochastic K% line must be in oversold territory
- Stochastic K% line must cross over Stochastic D% line
- Price as to close between slow EMA and fast EMA
Once all the conditions are true, a trade will start at the opening of the next

______ SETTINGS ______

- Trade Setup:
Here you can choose to trade only longs or shorts and change your Risk:Reward.
You can also decide to adjust your volume per position according to your risk tolerance. With “% of Equity” your stop loss will always be equal to a fixed percentage of your initial capital (will “compound” overtime) and with “$ Amount” your stop loss will always be 'x' amount of the base currency (ex: USD, will not compound)
Stop Loss:
The ATR is used to create a stop loss that matches current volatility. The multiplier corresponds to how many times the ATR stop losses and take profits will be away from closing price.

- Stochastic:
Here you can find the usual K% & D% length and overbought (OB) and oversold (OS) levels.
The “Stochastic OB/OS lookback” increase the tolerance towards OB/OS territories. It allows to look 'x' bars back for a value of the Stochastic K line to be overbought or oversold when detecting an entry signal.
The “All must be OB/OS” refers to the previous “Stochastic OB/OS lookback” parameter. If this option is ticked, instead of needing only 1 OB/OS value within the lookback period to get a valid signal, now, all bars looked back must be OB/OS.
The color gradient drawn between the fast and slow EMAs is a representation of the Stochastic K% line position. With default setting colors, when fast EMA > slow EMA, gradient will become solid blue when Stochastic is oversold and when slow EMA > fast EMA, gradient will become solid blue when Stochastic is overbought

- EMAs:
Just pick your favorite ones

- Reference Market:
An additional filter to be certain to stay aligned with the current a market index trend (in our case: Bitcoin). If selected reference market (and timeframe) is trading above selected EMA, this strategy will only take long trades (vice-versa for shorts) Because, let’s face it… even if this filter isn’t bulletproof, you know for sure that when Bitcoin tanks, there won’t be many Alts going north simultaneously. Once again, this is a trend following strategy.

A few tips for increased performance: fast EMA and D% Line can be real fast… 😉

As always, my scripts evolve greatly with your ideas and suggestions, keep them coming! I will gladly incorporate more functionalities as I go.
All my script are tradable when published but remain work in progress, looking for further improvements.

Hope you like it!
Release Notes:
Updated default settings
Release Notes:
Alerts() functions added for:
- Long trade start
- Short trade start
- Long stop or target activated
- Long stop or target activated

User input added for alert messages
This was designed in order for 3Commas users to simply copy/paste the "Messages" of their bots using TradingView custom signals.
Otherwise, you can input any message you like!

Feel free to get in touch with me if you want help setting up trading automation with 3Commas :)
Release Notes:
Typo in settings menu fixed

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?