HPotter

Average True Range Trailing Stops Strategy

Average True Range Trailing Stops Strategy, by Sylvain Vervoort
The related article is copyrighted material from Stocks & Commodities Jun 2009
즐겨찾기 스크립트에서 빼기 즐겨찾기 스크립트에 넣기
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 16/09/2014
// Average True Range Trailing Stops Strategy, by Sylvain Vervoort 
// The related article is copyrighted material from Stocks & Commodities Jun 2009 
////////////////////////////////////////////////////////////
study(title="Average True Range Trailing Stops Strategy, by Sylvain Vervoort", overlay = true)
nATRPeriod = input(5)
nATRMultip = input(3.5)
xATR = atr(nATRPeriod)
nLoss = nATRMultip * xATR
xATRTrailingStop = iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
                    iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss), 
                        iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))
pos =	iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1,
	    iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? red: pos == 1 ? green : blue )
plot(xATRTrailingStop, color=red, title="ATR Trailing Stop")

DONATE/TIP

BTC: 3FKWwtaYrf5NHZzaCi1fyAfQj7XSgtyCqe
Hi! Thanks for your work. How could I simulate the strategy to see the performance?
응답
HPotter AlfaCharts
응답
@HPotter, Many thanks
+1 응답
HPotter AlfaCharts
@AlfaCharts, You are welcome
응답
hello how to alert of average true strategy?
응답
HPotter kutibey
@kutibey, You can add this lines before barcolor

alertcondition(pos != pos and pos == 1, title='Signal Buy', message="Buy")
alertcondition(pos != pos and pos == -1, title='Signal Sell', message="Sell")
응답
kutibey HPotter
@HPotter, a very successful strategy does not repaint.thank you very much.
응답
HPotter kutibey
@kutibey, You are welcome
응답
@HPotter, how do i add it? source is locked
응답
HPotter diskursen
@diskursen, If I understand correctly. You should to press "Make a copy" in the Pine editor, then save and next edit in the new copy.
응답
홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 하우스룰(내부규정) 모더레이터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 Help Center 기능 개발/개선 요청 블로그 & 뉴스 잦은물음 위키 트위터
프로화일 프로화일설정 계정 및 빌링 트레이딩뷰 코인 나의 서포트 티켓 Help Center 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃