参考先前退出价格的 Pine 脚本入场策略

emo*_*phy 5 trading algorithmic-trading pine-script

我正在尝试在电视中建立一个策略(仅限多头头寸),其中strategy.entry将考虑之前的退出价格。例如:

strategy.entry("long", strategy.long, when = longcondition==true)
strategy.close("long", strategy.close, when = longcondition==false)
Run Code Online (Sandbox Code Playgroud)

除了 longcondition==true 之外,我还想为 Strategy.entry 插入另一个条件,它说明了以下意图:

strategy.entry("long", strategy.long, when = longcondition==true and close[1] < previousExitPrice)
Run Code Online (Sandbox Code Playgroud)

怎样做才正确呢?预先感谢您的答复。

Nic*_*kel -2

enterlong = 0;
if (longcondition == true and close[1] < previousExitPrice)
    enterlong := 1;

strategy.entry("long", strategy.long, when = enterlong)
Run Code Online (Sandbox Code Playgroud)