If statement 当条件为真时,尾随停止损失移动。松树文字

If statement 当条件为真时,尾随停止损失移动。松树文字,if-statement,pine-script,If Statement,Pine Script,我希望在我的策略中有一个持续的止损点。如果满足某个条件,它就会移动,然后停留在那里 简而言之,我想将SL的级别设置为输入 如果RSI超过yx=3,则大于2%=1%;如果价格超过BB线,则为5%Sl,如此类推 比如说 我从一个标准的固定SL开始 价格超过+2“后,我希望SL达到收支平衡 然后,如果价格达到多重条件,我希望SL再次移动 尝试很多不同的可能性,但可以让它变得更具吸引力 最后一次尝试 inputSlmove1 = 3*0.01 inputSLmoveset1 = 1*0.01 inpu

我希望在我的策略中有一个持续的止损点。如果满足某个条件,它就会移动,然后停留在那里

简而言之,我想将SL的级别设置为输入

如果RSI超过yx=3,则大于2%=1%;如果价格超过BB线,则为5%Sl,如此类推

比如说

我从一个标准的固定SL开始

价格超过+2“后,我希望SL达到收支平衡

然后,如果价格达到多重条件,我希望SL再次移动

尝试很多不同的可能性,但可以让它变得更具吸引力

最后一次尝试

inputSlmove1 = 3*0.01
inputSLmoveset1  = 1*0.01
inputSlmove2=5*0.01
inputSLmoveset1=2*0.01

SLtrigger = strategy.position_size > 0 and crossover(src1,strategy.position_avg_price * (1 + inputSlmove1))
SLtrigger2 = strategy.position_size > 0 and crossunder(src1,strategy.position_avg_price * (1 + inputSlmove2))

SLset1= strategy.position_avg_price *(1+(inputSLmoveset1*0)
Slset2=strategy.position_avg_price* (1+inputSLmoveset1)

SLL1 =0.0

if Sltrigger
    SLL1 := 1.0

if SLL1[1] == 1.0

SLL1 := 1.0

else

na

if SLL1 ==1

  SLset1
  
 
 if SLtrigger2
 SLL1:=2
 
 ... and so on
  
  
plot(SLset1 and strategy.position_size > 0, style=shape.triangledown ,location=location.abovebar, color=#388e3c, size=size.small, title='BB Buy 3')