Tradingview 5%止损

时间:2019-10-16 13:08:32

标签: pine-script

我正在尝试制定一个策略,该策略在x处买入,在y处卖出,并具有从x点开始固定的%stoploss。 因此,当我在x买入时,我想从输入点开始设定5%的止损。

//@version=4
strategy("Turtle Project",overlay= true)        
entry_long_2  =  input(55,   title="entry_long_2_input" ,minval=2)                
profit_long_2 =  input(20,   title="profit_long_2_input",minval=1)                




cond_L_2 = float(na)                                                             
cond_L_2:= if high[entry_long_2] >= highest(high,entry_long_2)                   
    high[entry_long_2]                                                            
else                                                                              
    cond_L_2[1]                                                                   


cond_L_P_2 = float(na)                                                            
cond_L_P_2:= if low[profit_long_2] <= lowest(low,profit_long_2)                   
    low[profit_long_2]                                                            
else                                                                            
    cond_L_P_2[1]                      



if high < cond_L_2
    strategy.entry("enter long",strategy.long, stop=cond_L_2)


//stoploss= needs to be a 5% stoploss from entry

strategy.exit("exit ","enter long",stop=cond_L_P_2)


plot(cond_L_2)
plot(cond_L_P_2, color=color.green)

希望som1可以提供帮助。btw我有多种短期和长期策略。

0 个答案:

没有答案
相关问题