ChartArt

Golden Cross, SMA 200 Moving Average Strategy (by ChartArt)

This famous moving average strategy is very easy to follow to decide when to buy (go long) and when to take profit.

The strategy goes long when the faster SMA 50 (the simple moving average of the last 50 bars) crosses above the slower SMA 200. Orders are closed when the SMA 50 crosses below the SMA 200. This simple strategy does not have any other stop loss or take profit money management logic. The strategy does not short and goes long only!

Here is an article explaining the "golden cross" strategy in more detail:
http://www.stockopedia.com/content/tradi...

On the S&P 500 index (symbol "SPX") this strategy worked on the daily chart 81% since price data is available since 1982. And on the DOW Jones Industrial Average (symbol "DOWI") this strategy worked on the daily chart 55% since price data is available since 1916. The low number of trades is in both cases not statistically significant though.


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.
즐겨찾기 스크립트에서 빼기 즐겨찾기 스크립트에 넣기
//@version=2
strategy("Golden Cross, SMA 200 Long Only, Moving Average Strategy (by ChartArt)", shorttitle="CA_-_Golden_Cross_Strat", overlay=true)

// ChartArt's Golden Cross Strategy
//
// Version 1.0
// Idea by ChartArt on June 19, 2016.
//
// This moving average strategy is very easy to follow:
//
// The strategy goes long when the faster SMA 50 (the
// simple moving average of the last 50 bars) crosses
// above the SMA 200. Orders are closed when the SMA 50
// crosses below SMA 200. The strategy does not short.
//
// This simple strategy does not have any other
// stop loss or take profit money management logic.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 


// Input
switch1=input(true, title="Enable Bar Color?")
switch2=input(false, title="Show Fast Moving Average")
switch3=input(true, title="Show Slow Moving Average")
movingaverage_fast = sma(close, input(50))
movingaverage_slow = sma(close, input(200))

// Calculation
bullish_cross = crossover(movingaverage_fast, movingaverage_slow)
bearish_cross = crossunder(movingaverage_fast, movingaverage_slow)

// Strategy
if bullish_cross
    strategy.entry("long", strategy.long)

strategy.close("long", when = bearish_cross )

// Colors
bartrendcolor = close > movingaverage_fast and close > movingaverage_slow and change(movingaverage_slow) > 0 ? green : close < movingaverage_fast and close < movingaverage_slow and change(movingaverage_slow) < 0 ? red : blue
barcolor(switch1?bartrendcolor:na)

// Output
plot(switch2?movingaverage_fast:na,color = change(movingaverage_fast) > 0 ? green : red,linewidth=3)
plot(switch3?movingaverage_slow:na,color = change(movingaverage_slow) > 0 ? green : red,linewidth=3)

//
alertcondition(bullish_cross, title='Golden Cross (bullish)', message='Bullish')
alertcondition(bearish_cross, title='Death Cross (bearish)', message='Bearish')
Do you know how to add stop loss?
if it goes below the price we enter -> EnterPrice - 100 or in case of shorting it -> EnterPrice + 100

Thank you for your awesome script
응답
This script worked well, but it appears Tradingview has changed their Pinescript code language. Now this script does not work anymore without making the code title much shorter:

change line 2:

strategy("Golden Cross, SMA 200 Long Only, Moving Average Strategy (by ChartArt)", shorttitle="CA_-_Golden_Cross_Strat", overlay=true)

to

strategy("Golden Cross", overlay=true)
+19 응답
홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 하우스룰(내부규정) 모더레이터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 도움 받기 기능 개발/개선 요청 블로그 & 뉴스 잦은물음 위키 트위터
프로화일 프로화일설정 계정 및 빌링 도움 받기 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃