Pine script Tradingview | strategy.exit()带有单独的出口

Pine script Tradingview | strategy.exit()带有单独的出口,pine-script,Pine Script,我对此代码有问题: strategy.entry("LONG", strategy.long, alert_message='{"action":"order","side":"buy","price":"'+tostring(close)+'"}') strategy.exit("STOP", "LONG", sto

我对此代码有问题:

strategy.entry("LONG", strategy.long, alert_message='{"action":"order","side":"buy","price":"'+tostring(close)+'"}')
strategy.exit("STOP", "LONG", stop=close * (1 - stop), alert_message='{"action":"close","side":"sell"}')
strategy.exit("PRFT", "LONG", limit=close * (1 + prft), alert_message='{"action":"profit","side":"sell"}')
*亏损/利润也有相同的止损/限价问题

只有第一个出口有效,在这种情况下,只有“停止”。我需要将这两个单独的文件发送到webhook

我尝试使用strategy.order()来制作我的“PRFT”,但是,回溯测试的结果却大不相同

我无法使用alertcondition(),因为它仅在蜡烛关闭后触发


有人能帮我吗?

也许这就是你发现的:

// @version=4
strategy("strategy")

stop = 0.05
prft = 0.05

strategy.entry("LONG", strategy.long, alert_message='{"action":"order","side":"buy","price":"'+tostring(close)+'"}')
if strategy.position_size != 0
    strategy.order("STOP", false, qty = strategy.position_size, oca_name = "exit long", oca_type = strategy.oca.reduce, stop=strategy.position_avg_price * (1 - stop), alert_message='{"action":"close","side":"sell"}')
    strategy.order("PRFT", false, qty = strategy.position_size, oca_name = "exit long", oca_type = strategy.oca.reduce, limit=strategy.position_avg_price * (1 + prft), alert_message='{"action":"profit","side":"sell"}')
else
    strategy.cancel("STOP")
    strategy.cancel("PRFT")