配置 "Order Size" 策略

Get configured "Order Size" of strategy

是否可以获取已配置的"Order Size"策略? 如果可以,怎么做?

我需要它来做一些 DCA 计算。

谢谢你的帮助!

参见 strategy.position_size

Direction and size of the current market position.
If the value is > 0, the market position is long.
If the value is < 0, the market position is short.
The absolute value is the number of contracts/shares/lots/units in trade (position size).

没有职位就无法获得Order size,但你可以这样做:

//@version=4
strategy("My Strategy", overlay=true)

var float posSize = na

if bar_index==0
    label.new(bar_index, high, "FirstBar")
    strategy.entry("Dummy entry", strategy.long, when=true)
if bar_index==1    
    posSize  := strategy.position_size
    strategy.cancel("Dummy entry", when=true)

plot(posSize)