如何在回测数据上准确绘制松脚本策略?

时间:2021-02-15 17:08:53

标签: pine-script

enter image description here

我有一个作为策略发布的松树脚本,但在查看回测数据时,买入和卖出信号显示的信号比实际信号晚 1-2 根蜡烛。

有人可以告诉我如何在准确的蜡烛图上绘制历史数据以获得更正确的交易摘要吗?

//@version=4
strategy("ABC[![enter image description here][1]][1]",calc_on_every_tick=true,overlay=false,default_qty_value=0,initial_capital=100000, currency=currency.USD,process_orders_on_close=false)
rsi_period = input(defval=9, title="RSI Period", type=input.integer)
wma_avg = input(defval=21, title="RSI WMA Period", type=input.integer)
ema_avg = input(defval=3, title="RSI EMA Period", type=input.integer)

bull_bear = input(defval=50, title="Line Value", type=input.integer)

rsi = rsi(close, rsi_period)
wma_v = wma(rsi, wma_avg)
ema_v = ema(rsi, ema_avg)


plot(wma_v, title='WMA', color=#d32f2f, style=plot.style_line, linewidth=2)
plot(ema_v, title="EMA", color=#00796b, style=plot.style_line, linewidth=1)

pl_rsi = plot(rsi, title='RSI', color=#363a45, style=plot.style_line, linewidth=1)

hmline = plot(50, title="Line", color=color.new(color.purple, 50),linewidth=1)

fill(pl_rsi,hmline, title = " Color Shade",color = rsi > bull_bear  ? color.new(#f44336,50) : color.new(#00bcd4,50))
//fill(pl_rsi,overbought, color = rsi < bull_sup ? color.red : na)

strategy.entry("Buy",true,1, when = ((rsi >= ema_v and rsi >= wma_v) and (ema_v >= wma_v)))
strategy.entry("Sell",false,1,when = ((rsi <= ema_v and rsi <= wma_v) and (ema_v <= wma_v)))

0 个答案:

没有答案