有时达到了获利回吐,但该策略可能会开启另一笔交易,并获得另一笔获利回吐

  • 本文关键字:一笔 交易 策略 pine-script trading
  • 更新时间 :
  • 英文 :


我的脚本有问题,为了优化收益,我想放一个获利回吐和止损(我已经在脚本中做了(

问题是,有时,达到了获利回吐,但该策略可能会打开另一个交易并获得另一个获利回吐(见屏幕(

我想知道该怎么告诉他。

如果达到获利回吐,但条件(多头或空头(仍然良好,则开启另一笔交易。

提前感谢那些将帮助我的人。

如果你想喜欢的话,我把策略放在下面。我目前正在SOLUSDT上测试它的3000米

屏幕

//@version=5
strategy("VortexStrategyEMA", overlay=true,  initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

AlerteBuy = input("Alerte BUY")
AlerteSell = input("Alerte SELL")
AlerteCloseBuy = input("Alerte CLOSE BUY")
AlerteCloseSell = input("Alerte CLOSE SELL")
//EMA
longer = (ta.ema(close, 100))
longest = (ta.ema(close, 200))
plot(longer, title="EMA100", color=#2962FF)
plot(longest,title="EMA200", color=#E91E63)
emahigh = (ta.ema(high,14))
emalow = (ta.ema(low,14))
//Vortex 
period_ = input.int(200, title="Length", minval=2)
VMP = math.sum( math.abs( emahigh - emalow[1]), period_ )
VMM = math.sum( math.abs( emalow - emahigh[1]), period_ )
STR = math.sum( ta.atr(1), period_ )
VIP = VMP / STR
VIM = VMM / STR
emaVIP = (ta.ema(VIP, 14))
emaVIM = (ta.ema(VIM, 14))
plot(VIP, title="VI +", color=#2962FF)
plot(VIM, title="VI -", color=#E91E63)
//ConditionsLONG
EMALONG = longer > longest
VortexLONG = ta.crossover(VIP,VIM)
LONG = VortexLONG and EMALONG
//ConditionsSHORT

EMASHORT = longer < longest
VortexSHORT = ta.crossunder(VIP,VIM)
SHORT = VortexSHORT and EMASHORT
//Strategy
strategy.entry("Long", strategy.long, when=LONG, comment="Long" ,  alert_message = AlerteBuy)
strategy.entry("Short", strategy.short, when=SHORT, comment="Short" ,   alert_message = AlerteSell)

stopPer = input(5, title='Stop Loss %') / 100
takePer = input(10, title='Take Profit %') / 100

// Determine where you've entered and in what direction
shortStop = strategy.position_avg_price * (1 + stopPer)
shortTake = strategy.position_avg_price * (1 - takePer)
longStop = strategy.position_avg_price * (1 - stopPer)
longTake = strategy.position_avg_price * (1 + takePer)

if strategy.position_size < 0
strategy.exit(id='Close Short', stop=shortStop, limit=shortTake,   alert_message = AlerteCloseSell)

if strategy.position_size > 0
strategy.exit(id='Close Long', stop=longStop, limit=longTake, alert_message = AlerteCloseBuy)

您可以将涡流长短的条件从交叉和交叉改为直接比较,如

VortexLONG = (VIP>VIM)

VortexSHORT = VIP<VIM

然后它将在退出后重新进入交易

最新更新