Professional Documents
Culture Documents
initial_capital=10000
// contracts
leverage = input.float(1, step=0.1)
balance = strategy.initial_capital + strategy.netprofit
contracts = leverage * balance/close
//如果赚钱的话则用本金投资,不复利
if balance > strategy.initial_capital
contracts = leverage * initial_capital/close
//MA TYPES
mat(source, length, type) =>
type == "SMA" ? ta.sma(source, length) :
type == "EMA" ? ta.ema(source, length) :
type == "RMA" ? ta.rma(source, length) :
type == "WMA" ? ta.wma(source, length) :
type == "VWMA" ? ta.vwma(source, length) :
type == "HMA" ? ta.hma(source, length) :
na
//---------------------------------------------------------------------------------
---------------------------------------------------------------------------
// SSL
Hlv1 = float(na)
Hlv1 := (wicks ? high : close) > ma1 ? 1 : (wicks ? low : close) < ma2 ? -1 :
Hlv1[1]
sslUp1 = Hlv1 < 0 ? ma2 : ma1
sslDown1 = Hlv1 < 0 ? ma1 : ma2
Hlv2 = float(na)
Hlv2 := (wicks ? high : close) > ma3 ? 1 : (wicks ? low : close) < ma4 ? -1 :
Hlv2[1]
sslUp2 = Hlv2 < 0 ? ma4 : ma3
sslDown2 = Hlv2 < 0 ? ma3 : ma4
if long_cond
strategy.entry("long_entry", strategy.long, qty=contracts)
if short_cond
strategy.entry("short_entry", strategy.short, qty=contracts)
//strategy.close("long_entry")