在 Pine 中,为什么入场条件为偶数时策略在奇数索引柱上入场?

问题描述 投票:0回答:0

我的代码,我明确指定应在偶数柱上制作入场订单

//@version=5
strategy("TEST STRATEGY 2", overlay=true)


backtestStartDate = input.time(timestamp("01 Apr 2023 12:05:00 GMT+02:00"), title="Start Date", group="Backtest Time Period")
backtestEndDate = input.time(timestamp("01 Apr 2023 12:15:00 GMT+02:00"), title="End Date", group="Backtest Time Period")
inTradeWindow = time > backtestStartDate and time <= backtestEndDate


if inTradeWindow


    if bar_index % 2 == 0
        strategy.entry("My Long Entry", strategy.long)
    else
        strategy.close("My Short Entry")


    a = str.tostring(bar_index)
    label.new(bar_index, na, a, yloc = yloc.abovebar, size = size.normal,textcolor = color.white)

然而,恰恰相反:

pine-script
© www.soinside.com 2019 - 2024. All rights reserved.