我如何将Pinescript设置为仅比原始指标高5%的价格购买一次

时间:2019-10-29 10:49:47

标签: pine-script

我需要我的pinescript仅在指标设置好后设置买入订单,然后上涨5%并且条件或指标仍然为真。

下面是我当前的代码,我需要修改什么? 有关如何执行此操作的任何想法? 任何帮助将不胜感激

// @ version = 2 策略(“ EMA仅长期策略”,overlay = true,default_qty_type = strategy.percent_of_equity,default_qty_value = 100)

len = input(21, type=integer, minval=1, title="Length")

price = sma(close, 2)
average = ema(close, len)
diff = atr(len)
bull_level = average + diff
bear_level = average - diff
bull_cross = crossover(price, bull_level)
bear_cross = crossover(bear_level, price)

strategy.entry("Buy", strategy.long, when=bull_cross) 
strategy.close("Buy", when=bear_cross) //strategy.entry("Sell", 
strategy.short, when=bear_cross)

plot(price, title="price", color=green, transp=50, linewidth = 4)
plot(average, title="average", color=red, transp=50, linewidth = 4)
a1 = plot(bull_level, title="bull", color=red, transp=50, linewidth = 1)
a2 = plot(bear_level, title="bear", color=red, transp=50, linewidth = 1)
fill(a2, a1, color=red, transp=95)

0 个答案:

没有答案