3

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

strategy.entry("long", strategy.long, when = longcondition==true)
strategy.close("long", strategy.close, when = longcondition==false)

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

strategy.entry("long", strategy.long, when = longcondition==true and close[1] < previousExitPrice)

如何正确执行?预先感谢您的回答。

4

2 回答 2

1

我不知道你的多头条件是什么,但如果是市场卖出,你可以尝试使用if而不是when设置退出价格和退出订单:

previousExitPrice = 0.0
previousExitPrice := nz(previousExitPrice[1]) //this will put the variable in memory

strategy.entry("long", strategy.long, when = longcondition==true and close[1] < previousExitPrice)

if longcondition==false
    strategy.close("long", strategy.close)
    previousExitPrice := close //in case of market sell
于 2020-04-29T22:14:26.843 回答
-2
enterlong = 0;
if (longcondition == true and close[1] < previousExitPrice)
    enterlong := 1;

strategy.entry("long", strategy.long, when = enterlong)
于 2018-10-23T22:37:19.390 回答