HPotter

Extracting The Trend Strategy

1705 visningar
160
The related article is copyrighted material from Stocks & Commodities Mar 2010
You can use in the xPrice any series: Open, High, Low, Close, HL2 , HLC3, OHLC4 and ect...
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 16/10/2014
// The related article is copyrighted material from Stocks & Commodities Mar 2010
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
////////////////////////////////////////////////////////////
study(title="Extracting The Trend Strategy")
Length = input(20, minval=1)
Delta = input(0.5)
Trigger = input(0)
hline(Trigger, color=blue, linestyle=line)
xPrice = hl2
beta = cos(3.1415 * (360 / Length) / 180)
gamma = 1 / cos(3.1415 * (720 * Delta / Length) / 180)
alpha = gamma - sqrt(gamma * gamma - 1)
xBandpassFilter = 0.5 * (1 - alpha) * (xPrice - xPrice[2]) + beta * (1 + alpha) * nz(xBandpassFilter[1]) - alpha * nz(xBandpassFilter[2])
xMean = sma(xBandpassFilter, 2 * Length)
pos =	iff(xMean > Trigger, 1,
	    iff(xMean < Trigger, -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? red: pos == 1 ? green : blue )
plot(xMean, color=red, title="ExTrend")
Donate BTC: 13fXLkhWuGMXRmcvwkG2gaWKcnsiD88bwE
USDT (TRC20): TH29EEXa19vfwZNYvxdUuMxoFY5QDYLcWG

Kommentarer

Another HP great addition to the public library.
Svara
Thanks for sharing the script.
Svara
HPotter aleipena
You are welcome.
Svara
Hem Aktie-screener Forex-screener Krypto-screener Ekonomisk kalender Om Diagramfunktioner Priser Tipsa en vän Ordningsregler Hjälpcenter Webbsidor och mäklarlösningar Widgets Diagramlösningar Lightweight Charting Library Blogg och nyheter Twitter