使用 PineScript 时,我无法在交易视图警报中看到绘图变量,并且无法在柱的末端输入头寸

问题描述

我正在使用 Pine Script 来测试策略。我试图在进入某个位置时收到警报。但是,我无法在警报中获得所需的变量。我正在使用绘图功能,您很快就会看到。我找不到我的错误。感谢您的帮助。

if ((long or short) and time >= start and barstate.isconfirmed[1])
    takeMarketProfit := long? (close-stopLoss)  * gain + close : short? close - (stopLoss-close) * gain : na

plot(series=(stopLoss),title="StopLoss",color=color.orange)
plot(series=(takeMarketProfit),title="TakeMarketProfit",color=color.lime)

if (long and time >= start and barstate.isconfirmed[1])
    strategy.entry("Long",strategy.long,when = (long and notinPos and barstate.isconfirmed[1]))
    strategy.exit(id="Long",limit=takeMarketProfit,stop=stopLoss)
    notinPos := false
    inPos := true
if (short and time >= start and barstate.isconfirmed[1])
    strategy.entry("Short",strategy.short,when = (short and notinPos and barstate.isconfirmed[1]))
    strategy.exit(id="Short",stop=stopLoss)
    notinPos := false
    inPos := true

我的报警代码可以在下面看到,也是从报警 GUI 设置的。

{
"passphrase": "professorgeliyor","time": "2021-06-04T11:07:00Z","exchange": "BINANCE","ticker": "ETHUSDT","bar": {
"time": "2021-06-04T11:07:00Z","open": 2627,"high": 2627.58,"low": 2627,"close": 2627.58,"volume": 0.02559
},"strategy":{
"position_size": -2.263,"order_action": sell,"order_contracts": 2.263,"order_price": 2627.58,"StopLoss": {{plot("StopLoss")}},"TakeMarketProfit": {{plot("TakeMarketProfit")}},"mintick": {{plot("Mintick")}},"dir": {{plot("Dir")}},"order_id": "Short","market_position": short,"market_position_size": 2.263,}
}

我想获取 plot("StopLoss") 和其他值。 作为第二个问题,我可能会提出一个新问题,即我无法在柱线收盘时进入头寸。我几乎尝试了所有方法,但在栏仍处于活动状态时仍会出现条目。我正在使用 1 分钟图表。如果你也能帮我解决这个问题,我会非常高兴。我也试过 barstate.isconfirmed 而不是 barstate.isconfirmed[1]。而我的策略功能

strategy("Professor",process_orders_on_close=true,overlay=true,currency = 'USD',initial_capital = 10000,default_qty_value = 50,default_qty_type = strategy.percent_of_equity,commission_type = strategy.commission.percent,commission_value = 0.1)

谢谢:)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)