我在 TradingView 中有一个根据特定条件做多的策略。如果我对止损和止盈使用整数或百分比,效果会很好。
但是,我真的想将止损设置在之前的低点。
在执行 Long 时,我似乎无法保存变量。
下面不起作用,因为每根蜡烛都会更新 low[1]:
inpTakeProfit = input(2.0, title='Take Profit %', type=float)/100
takeProfitValue = strategy.position_avg_price * (1 + inpTakeProfit)
inpStopLoss = low[1]
stopLossValue = inpStopLoss
entry = strategy.position_avg_price
useTakeProfit = inpTakeProfit > 0 ? takeProfitValue : na
useStopLoss = inpStopLoss > 0 ? stopLossValue : na
如何保存变量并使其保持静态?