TradingView
lucagast
10 lug 2017 09:16

Strategia molto semplice su E-mini S&P Long

E-mini S&P 500 FuturesCME

Descrizione

Questa è una strategia che sfrutta la tendenza mean-reversion presente sugli indici americani da molti anni. Si va long quando la chiusura della barra giornaliera è inferiore alla chiusura di 2 giorni fa. Si esce dal long quando la chiusura della barra giornaliera è superiore a quella di 2 giorni fa. Funziona al meglio su grafici daily, ma potrebbe essere usata anche sul settimanale.

Commento

//@version=2
strategy("C<C[2]", overlay=true)
testStartYear = input(2003, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(6, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

testPeriod() =>
time >= testPeriodStart and time <= testPeriodStop ? true : false
strategy.entry("WR long",true, when = close < close[2] and testPeriod())
strategy.close("WR long", when = close > close[2])

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
Commenti
Matdea1907
Ciao, bella idea! Riesci a condividere lo script? Grazie.
lucagast
@Matdea1907, lo script è il seguente :

//@version=2
strategy("ACF", overlay=true)
length = input(2)
hh = highest(high, length)
ll = lowest(low, length)

if (not na(close[length]))
strategy.entry("ACFLE", strategy.long, comment="ACFLE", limit= ll )
strategy.exit("ACFLX", "ACFLE", limit=hh)

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
Altro