TradingView
UDAY_C_Santhakumar
15 Mac 2015 pukul 23.36

TSM Donchian Moving Average System_by_ucsgears 

SPDR Select Sector Fund - Health CareArca

Huraian

This is just the raw code for the system / strategies.

Will Complete this when I get more time.

Green - Setup Long
Red - Setup Short
Komen
UDAY_C_Santhakumar



New and improved update, with better filters.
P7
Thank you very much for sharing ucsgears, did you use RSI as filter this time by any chance ?
UDAY_C_Santhakumar
no. Its just different overlay indicators to serve the same purpose.
Days_Off
Nice work ucsgears. Here it is as a strategy...

//@version=2

strategy("TSM Donchian Moving Average System", default_qty_value=1, initial_capital=50000, currency=currency.USD,commission_type=strategy.commission.percent,commission_value=0.05, overlay = true)

a = input(20, title = "Long Period")
b = input(5, title = "Short Period")
ca = input(1, title = "Band Factor")
buyinput = input(true, title = "Enable Buy")
sellinput = input(true, title = "Enable Sell")

// Moving average
malong = sma(close,a)
mashort = sma(close,b)
range = sma(tr, a)*ca
kclupper = malong + range
kcllower = malong - range

kcsupper = mashort + range
kcslower = mashort - range

// PLOT
plot(malong, offset=1, title = "SMA Long")
plot(mashort, offset=1, title = "SMA Short")
plot(kclupper, offset=1, title = "KC Upper")
plot(kcllower, offset=1, title = "KC Lower")

// SETUP
// LONG
setuplong = close > kclupper[1] and close > kcsupper[1] ? green : na
setupshort = close < kcllower[1] and close < kcslower[1] ? red : na

barcolor(setuplong)
barcolor(setupshort)

// === ALERTS ===
if buyinput==true
if (close > kclupper[1] and close > kcsupper[1])
strategy.entry("L", strategy.long)

if (close < kcllower[1] and close < kcslower[1])
strategy.close("L")

if sellinput==true
if (close < kcllower[1] and close < kcslower[1])
strategy.entry("S", strategy.short)

if (close > kclupper[1] and close > kcsupper[1])
strategy.close("S")
UDAY_C_Santhakumar
@Days_Off, Love it
thanveer
@Days_Off, 3:10:47 PM Error at 37:0 mismatched input 'if' expecting 'end of line without line continuation'
tesermhmd1
Good
mahatango747
How do you activate the Exit Long section? For some reason the short side of the code doesn't work.
UDAY_C_Santhakumar
@mahatango747, I haven't finished the exit codes. Take a stab at it, if you want to
ADmytrenko2
@ucsgears, This is the best strategy out there, works quite well. Was wondering if you'll finish the code? Lol
Lebih