我是 Pine 的新手,我正在尝试将以下策略转化为一项研究:
@commands.is_owner() #make sure no one else uses it
@bot.command()
async def stop_bot(ctx):
exit()
这是我目前的尝试:
//@version=4
strategy(title="test", default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=.0020, pyramiding=0, slippage=3, overlay=true)
ema8 = ema(close, 8)
ema13 = ema(close, 13)
ema55 = ema(close, 55)
longEmaCondition = ema8 > ema13
exitLongEmaCondition = ema13 < ema55
// STRATEGY //
longCondition = longEmaCondition and strategy.position_size == 0
exitLongCondition = exitLongEmaCondition and strategy.position_size > 0
if longCondition
strategy.entry("LONG", strategy.long)
if exitLongCondition
strategy.close("LONG")
然而,当绘制上图时,有很多金字塔交易(见下面的图片链接)。我该如何阻止?我删除了 //@version=4
study("My Script",overlay = true)
ema8 = ema(close, 8)
ema13 = ema(close, 13)
ema55 = ema(close, 55)
longEmaCondition = ema8 > ema13
exitLongEmaCondition = ema13 < ema55
// STRATEGY //
longCondition = longEmaCondition
exitLongCondition = exitLongEmaCondition
alertcondition(longCondition, title = "Entry Long")
alertcondition(exitLongCondition, title = "Exit Long")
plotshape(longCondition,text='LONG' ,color=color.green, location=location.abovebar,style=shape.arrowup)
plotshape(exitLongCondition, color=color.green,text='Close \n LONG', location=location.belowbar)
变量,因为我在 Study 脚本中找不到等效的函数。这是造成金字塔效应的原因吗?
任何帮助将不胜感激。