【问题标题】:How to make a strategy enter in the middle of current bar?如何让策略进入当前柱的中间?
【发布时间】:2019-11-11 02:07:15
【问题描述】:

我尝试了一个非常简单的策略,如下所示,

VB_signal = (close - open) > high[1] - low[1]

strategy.entry("VB_buy", strategy.long, when = VB_signal)
strategy.close("VB_buy", when = barstate.isnew)

当前价格超过开盘价+前一根柱线区间(高-低),立即进入当前柱线中间。

但是当我回测这个策略时,策略总是在当前柱收盘后进入(下一个柱的开始)我怎样才能让这个策略进入当前柱的中间?强>

在下图中,

Wanted to enter in the middle of second bar, but it enters on 3rd bar.

【问题讨论】:

    标签: algorithmic-trading trading pine-script


    【解决方案1】:

    在历史和实时计算过程中,代码默认在柱收盘上计算。

    来源:Backtesting and Forwardtesting

    【讨论】:

    • 我明白了,所以我无法让它在当前栏的中间“进入”??
    • 对于策略,没有。您可以尝试使用指示器来执行此操作并为该条件设置警报,但是您将遇到很多重绘问题。
    猜你喜欢
    • 2022-12-18
    • 1970-01-01
    • 2022-11-13
    • 2020-04-26
    • 2019-10-19
    • 1970-01-01
    • 2023-01-27
    • 1970-01-01
    • 2012-10-03
    相关资源
    最近更新 更多