HPotter

Average True Range Trailing Stops Colored

Average True Range Trailing Stops Strategy, by Sylvain Vervoort
The related article is copyrighted material from Stocks & Commodities Jun 2009
Favori Komutlardan Çıkart Favori Komutlara Ekle
////////////////////////////////////////////////////////////
//  Copyright by HPotter v2.0 13/10/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))) 
color = pos == -1 ? red: pos == 1 ? green : blue 
plot(xATRTrailingStop, color=color, title="ATR Trailing Stop")

DONATE/TIP

BTC: 3FKWwtaYrf5NHZzaCi1fyAfQj7XSgtyCqe
good job harry keep going
Cevap Gönder
HPotter coinalert
@coinalert, You are welcome.
Cevap Gönder
Hey! Thanks for the script!
Question: Is it repainting?
+1 Cevap Gönder
HPotter TraderPavlos
@TraderPavlos, You are welcome. Should be.
Cevap Gönder
Hi thanks for the script, it's very useful!

Is it possible to use it with "//@version=2" parameter?

best regards, Luca
Cevap Gönder
LucaManghi LucaManghi
Never mind, I have adapted my script, now it works without the "//@version=2".

Thanks again for sharing the script, Luca
Cevap Gönder
HPotter LucaManghi
You are welcome.
Cevap Gönder
vacalo69 LucaManghi
@LucaManghi, Hello can you please send me the pine code to work with "//@version=2". ? Appreciate it!
Cevap Gönder
Hi, Thank you for posting this. I am very new to this concept and wish to ask what may be a stupid question. Here goes anyway:

Example: I have a max risk goal of not to lose more than 2% on any given trade.

1.) How would I set the inputs for this?

I have read some stuff on what is called an Average True Range Dynamic Stop.

2.) Is your script an ATR Dynamic Stop or something else?

Thanks

+2 Cevap Gönder
HPotter Codetrader
Hi, codetrader
1) I can`t recomendet to you anything. I don`t use this script, I just coding it from magazine Stocks & Commodities Jun 2009. Sorry.

2) This script recalculated on the realtime and make changes in the stoploss level dynamically.
+1 Cevap Gönder
Ana Sayfa Hisse Senedi Takipçisi Forex Takipçisi Kripto Takipçisi Ekonomik Takvim Nasıl Çalışır Grafik Özellikleri Ücretlendirme Kurallarımız Moderatörler Web Sitesi & Aracı Kurum Çözümleri Görsel Bileşenler(Widget) Grafik Çözümleri Yardım Alın Yeni Özellik Talebi Blog ve Haberler SSS Viki Twitter
Profil Profil Ayarları Hesap ve Ödemeler Yardım Alın Yayınlanmış Fikirler Takip Edenler Takip Ediliyor Özel Mesajlar Sohbet Çıkış