The Exponential Smoothed Stochastic Oscillator strategy is a modified version of the traditional stochastic indicator by adding an exponential weight parameter to adjust the sensitivity of the stochastic and generate trading signals. It goes long when the indicator crosses over from overbought levels and goes short when the indicator crosses under from oversold levels. The optimized strategy can become a very stable trend following strategy.
The core of the Exponential Smoothed Stochastic strategy lies in the exponential weight parameter ex. The traditional stochastic is calculated as:
s = 100 * (close - lowest low) / (highest high - lowest low)
With the exponential parameter, the formula becomes:
exp = ex<10? (ex)/(10-ex) : 99
s = 100 * (close - lowest low) / (highest high - lowest low)
ks = s>50? math.pow(math.abs(s-50),exp)/math.pow(50,exp-1)+50
:-math.pow(math.abs(s-50),exp)/math.pow(50,exp-1)+50
By adjusting exp, the influence of s on ks can be changed. Increasing exp makes the indicator less sensitive while decreasing exp makes it more sensitive.
Buy signals are generated when ks crosses over from overbought levels. Sell signals are generated when ks crosses under from oversold levels.
Compared to the traditional stochastic strategy, the Exponential Smoothed Stochastic Oscillator strategy has the following advantages:
The Exponential Smoothed Stochastic Oscillator strategy also has the following risks:
The Exponential Smoothed Stochastic Oscillator strategy can be optimized from the following aspects:
The Exponential Smoothed Stochastic Oscillator strategy generates more reliable trading signals by adjusting the sensitivity of the stochastic indicator. It can effectively track medium-to-long term trends and can also be optimized into a short-term strategy. With further composability and parameter optimization, it has the potential to achieve more consistent profitable returns.
/*backtest start: 2023-01-11 00:00:00 end: 2024-01-17 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © faytterro //@version=5 strategy("Exponential Stochastic Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100) len=input.int(14, "length") ex=input.int(2, title="exp", minval=1, maxval=10) exp= ex<10? (ex)/(10-ex) : 99 s=100 * (close - ta.lowest(low, len)) / (ta.highest(high, len) - ta.lowest(low, len)) ks=s>50? math.pow(math.abs(s-50),exp)/math.pow(50,exp-1)+50 : -math.pow(math.abs(s-50),exp)/math.pow(50,exp-1)+50 plot(ks, color= color.white) bot=input.int(20) top=input.int(80) longCondition = ta.crossover(ks, bot) and bar_index>0 if (longCondition) strategy.entry("My Long Entry Id", strategy.long) shortCondition = ta.crossunder(ks, top) and bar_index>0 if (shortCondition) strategy.entry("My Short Entry Id", strategy.short) // strategy.close("My Long Entry Id") alertcondition(longCondition, title = "buy") alertcondition(shortCondition, title = "sell") h1=hline(top) h2=hline(bot) h3=hline(100) h4=hline(0) fill(h1,h3, color= color.rgb(255,0,0,200-top*2)) fill(h2,h4, color= color.rgb(0,255,0,bot*2))