BINANCE:BTCUSDT.P   Bitcoin / TetherUS PERPETUAL CONTRACT
//@version=5
strategy("EMA cross [odnac] long-close",
 overlay=true,
 initial_capital = 1000,
 default_qty_type = strategy.percent_of_equity,
 default_qty_value = 100,
 commission_type = strategy.commission.percent,
 commission_value = 0.04, 
 process_orders_on_close = true)

// time
startDate = input.time(timestamp('2017-01-02T00:00:00'), title='Start Date')
finishDate = input.time(timestamp('2100-12-31T00:00:00'), title='End Date')
time_cond = startDate <= time and time <= finishDate

// EMA
short_length = input(5, "short_length")
long_length = input(10, "long_length")

ema5 = ta.ema(close, short_length)
ema10 = ta.ema(close, long_length)

plot(ema5, color = color.red)
plot(ema10, color = color.yellow)

// condition
long = ta.crossover(ema5, ema10)
long_close = ta.crossunder(close, ema10)
long_sl = input(2, "stop loss")
long_exit = strategy.position_avg_price * ( ( 100 - long_sl ) / 100 )

// plotshape(series = long, location = location.belowbar, style = shape.labelup, color = color.rgb(76, 175, 79, 50) , text = "entry", size = size.auto, textcolor = color.white)
// plotshape(series = long_close, location = location.abovebar, style = shape.labeldown, color = color.rgb(255, 82, 82, 50) , text = "close", size = size.auto, textcolor = color.white)

if time_cond
    if long
        strategy.entry("long", strategy.long)

    if long_close
        strategy.close("long")

    if long_exit
        strategy.exit("exit", "long", stop = long_exit)
면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.