ChartArt

MACD + Stochastic, Double Strategy (by ChartArt)

This strategy combines the classic stochastic strategy to buy when the stochastic is oversold with a classic MACD strategy to buy when the MACD histogram value goes above the zero line. Only difference to the classic stochastic is a default setting of 71 for overbought (classic setting 80) and 29 for oversold (classic setting 20).

Therefore this strategy goes long if the MACD histogram goes above zero and the stochastic indicator detects a oversold condition (value below 29). If the inverse logic is true, the strategy goes short (stochastic overbought condition with a value above 71 and the MACD histogram falling below the zero line value).

Please be aware that this pure double strategy using simply two classic indicators does not have any stop loss or take profit money management logic.

All trading involves high risk; past performance is not necessarily indicative of future results. Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//@version=2
strategy("MACD + Stochastic, Double Strategy (by ChartArt)", shorttitle="CA_-_MACD_Stoch_Strat", overlay=true)

// ChartArt's MACD + Stochastic Strategy
//
// Version 1.0
// Idea by ChartArt on February 24, 2016.
//
// This strategy combines the classic stochastic
// strategy to buy when the stochastic is oversold
// with a classic MACD strategy to buy when the
// MACD histogram value goes above the zero line.
//
// Only difference to the classic stochastic is a
// default setting of 71 for overbought
// (classic setting 80) and 29 for oversold
// (classic setting 20).
//
// This strategy goes long if the MACD histogram
// goes above zero and the stochastic indicator
// detects a oversold condition (value below 29).
// If the inverse logic is true, the strategy
// goes short (oversold condition value above 71).
//
// This pure double strategy does not have any
// stop loss or take profit money management logic.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 

// Input
fastMAlen = input(12, minval=1, title="MACD fast moving average")
slowMAlen = input(26,minval=1, title="MACD slow moving average")
signalMACDlen = input(9,minval=1, title="MACD signal line moving average")
StochLength = input(14, minval=1, title="Stochastic Length")
OverBoughtOverSold = input(71, title="Overbought Level (Oversold = 100 - Overbought")
switch=input(true, title="Enable MACD Bar Color?")

// MACD Calculation
MACD = ema(close, fastMAlen) - ema(close, slowMAlen)
signalMACD = ema(MACD, signalMACDlen)
delta = MACD - signalMACD
fastMA = ema(close,fastMAlen)
slowMA = ema(close,slowMAlen)
veryslowMA = sma(close, 100)

// Stochastic Calculation
OverBought = OverBoughtOverSold
OverSold = 100-OverBought
smoothK = input(3, title="Smoothing of Stochastic %K ")
smoothD = input(2, title="Moving Average of Stochastic %K")
k = sma(stoch(close, high, low, StochLength), smoothK)
d = sma(k, smoothD)

// Colors
bartrendcolor = close > fastMA and close > slowMA and close > veryslowMA and change(slowMA) > 0 ? green : close < fastMA and close < slowMA and close < veryslowMA and change(slowMA) < 0 ? red : blue
barcolor(switch?bartrendcolor:na)

// Strategy
if (not na(k) and not na(d))
    if (crossover(k,d) and k < OverSold and crossover(delta, 0))
        strategy.entry("Stoch_L__MACD_L", strategy.long, comment="Stoch_L_+_MACD_L")
    if (crossunder(k,d) and k > OverBought and crossunder(delta, 0))
        strategy.entry("Stoch_S__MACD_S", strategy.short, comment="Stoch_S_+_MACD_S")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)