首页 > 解决方案 > 使用 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", limit=takeMarketProfit, 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)

谢谢 :)

标签: pine-scriptalarmtradingbinance

解决方案


推荐阅读