我正在尝试在电视中建立一种策略(仅限多头头寸),其中 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)
如何正确执行?预先感谢您的回答。
答案 0 :(得分:0)
我不能说出您的多头头寸是什么,但是如果是市场卖出,您可以尝试使用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
答案 1 :(得分:-1)
enterlong = 0;
if (longcondition == true and close[1] < previousExitPrice)
enterlong := 1;
strategy.entry("long", strategy.long, when = enterlong)