TradingView
HNipps
25 יוני 2018 11:42

Moving Average Mean Reversion Strategy 

Bitcoin / DollarBitfinex

תיאור

A basic mean-reversion strategy. Shorts when the close is 10% above the MA, and goes long when it's 10% below the MA.
תגובות
HermanBrummer
Tested in on SPY which has data going back to 1993 -- this system had 3 trades during that time. Actually this is not really even a system, as it just based on close price *1.1 and close price *.90 for the bands. That's not deviation, just fixed percentage values
HermanBrummer
ver 4 code
//@version=4
strategy(title="Moving Average Mean Reversion Strategy", shorttitle="MA-MR", overlay=true)
len = input(20, minval=1, title="Length")
src = input(close, title="Source")
out = sma(src, len)

plot(out*1.1, color=color.green, title="MA")
plot(out*0.9, color=color.green, title="MA")
plot(out, color=color.blue, title="MA")
plot(close, color=color.red, title="Close")

upper_bound = out * 1.1
lower_bound = out * 0.9

if crossunder(close, lower_bound)
strategy.entry("buy", strategy.long, comment="MR-LE")

if crossover(close, upper_bound)
strategy.entry("sell", strategy.short, comment="MR-SE")
Dex7er_
@HermanBrummer, You forgot indentat
if crossunder(close, lower_bound)
strategy.entry("buy", strategy.long, comment="MR-LE")

if crossover(close, upper_bound)
strategy.entry("sell", strategy.short, comment="MR-SE")
Dex7er_
@Dex7er_, Probably not =)
TV delete my indentat
עוד