[英]Get the price when exit/close strategy
它可以使用 strategy.opentrades.entry_price(0) 获取策略进入时的价格。 但是如何在策略退出/关闭时获得价格?
嗯,同样,有
strategy.closedtrades.exit_price(strategy.closedtrades - 1)
例如:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius
//@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
exit_price = strategy.closedtrades.entry_price(strategy.closedtrades-1)
plot(exit_price, "", color.red, 2, plot.style_circles)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.