问题描述
下图中所指的那些绿线和红线实际上是我的算法之前给我的一个信号的止损和获利。我实际上希望这条线在我的 tp 或止损被触及或价格越过我的基线反向时不再显示。
这是我使用的代码:
use_tp = input(false,title = "Use Take Profit ?",type=input.bool)
// Store values
entry_atr = float(0.0) //set float
entry_price = float(0.0) //set float
entry_atr := Buy or Sell ? atr : entry_atr[1]
entry_price := Buy or Sell ? close : entry_price[1]
//Calculate the stop loss and take profit distance in price
xLoss = entry_atr * atrMulti_Loss
xProfit = entry_atr*atrMulti_Profit
//find long entry stop loss and take profit
long_stop_level = float(0.0) //set float
long_profit_level = float(0.0) //set float long_stop_level := entry_price - xLoss long_profit_level := entry_price + xProfit
//find short entry stop loss and take profit
short_stop_level = float(0.0) // set float
short_profit_level = float(0.0) // set float
short_stop_level := entry_price + xLoss short_profit_level := entry_price - xProfit
take_profit_long = use_tp ? long_profit_level : na
take_profit_short = use_tp ? short_profit_level : na
//Plot stop loss and profit level on chart,hide levels when no Trade
plot(Buy ? na : long_stop_level,color=color.red,style=plot.style_linebr,linewidth = 2)
plot(Buy ? na : take_profit_long,color=color.lime,linewidth = 2)
plot(Sell ? na : short_stop_level,linewidth = 2)
plot(Sell ? na : take_profit_short,linewidth = 2)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)