我想在价格越过紫红色线后尝试进场,并有一个带有 4 条上线的追踪止损(退出价格明显向上移动)。非常感谢任何帮助!
//@version=4
strategy(shorttitle="Draft", title="Fibonacci Bollinger Bands", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100, initial_capital = 25000, pyramid = 4)
length = input(200, minval=1)
src = input(hlc3, title="Source")
mult = input(3.0, minval=0.001, maxval=50)
basis = vwma(src, length)
dev = mult * stdev(src, length)
upper_1= basis + (0.236*dev)
upper_2= basis + (0.382*dev)
upper_3= basis + (0.5*dev)
upper_4= basis + (0.618*dev)
upper_5= basis + (0.764*dev)
upper_6= basis + (1*dev)
lower_1= basis - (0.236*dev)
lower_2= basis - (0.382*dev)
lower_3= basis - (0.5*dev)
lower_4= basis - (0.618*dev)
lower_5= basis - (0.764*dev)
lower_6= basis - (1*dev)
PX = plot(basis, "2", color.fuchsia, linewidth=2)
p1 = plot(upper_1, "0.236", color.white, linewidth=1)
p2 = plot(upper_2, "0.382", color.white, linewidth=1)
p3 = plot(upper_3, "0.5", color.white, linewidth=1)
p4 = plot(upper_4, "0.618", color.white, linewidth=1)
p5 = plot(upper_5, "0.764", color.white, linewidth=1)
p6 = plot(upper_6, "1", color.red, linewidth=2)
p13 = plot(lower_1, "0.236", color.white, linewidth=1)
p14 = plot(lower_2, "0.382", color.white, linewidth=1)
p15 = plot(lower_3, "0.5", color.white, linewidth=1)
p16 = plot(lower_4, "0.618", color.white, linewidth=1)
p17 = plot(lower_5, "0.764", color.white, linewidth=1)
p18 = plot(lower_6, "1", color.green, linewidth=2)
// Determine long and short conditions
strategy.risk.allow_entry_in(strategy.direction.long)
Long = crossover(close, basis)
exitLong = crossover(close, upper_1) or crossover(close, upper_2) or crossover(close, upper_3) or crossover(close, upper_4)
// Submit orders
start = timestamp(2021, 1, 1, 0, 0)
end = timestamp(2021, 7, 1, 0, 0)
if time >= start and time <= end
strategy.entry("Long", strategy.long, when = Long, alert_message = "Buy!")
strategy.close("Long", when = exitLong)