我的入场应该只有在前一个高点[1]被突破之后,在所有条件都满足之后

问题描述 投票:0回答:0

请帮我获取突破入口代码

//@version=5
strategy('strategy final', overlay=true)

//VWAP
price = input(defval=hlc3, title='VWAP Source')
enable_vwap = input(true, title='Enable VWAP')
vwapResolution = input.timeframe(title='VWAP Resolution', defval='')
vwapFunction = ta.vwap(price)
vwapSecurity = request.security(syminfo.tickerid, vwapResolution, vwapFunction)
plot(enable_vwap ? vwapSecurity : na, title='VWAP', color=color.red, linewidth=2, editable=true)
pvwap = ta.vwap


//EMA
res_EMA = input.timeframe(title='EMA Timeframe', defval='D')
len = input(title='EMA Length', defval=50)
col = input(title='Color EMA', defval=true)
smooth = input(title='Smooth', defval=false)

eema = ta.ema(close, len)
emaSmooth = request.security(syminfo.tickerid, res_EMA, eema, barmerge.gaps_on, barmerge.lookahead_off)
emaStep = request.security(syminfo.tickerid, res_EMA, eema, barmerge.gaps_off, barmerge.lookahead_off)
plot(smooth ? emaSmooth : emaStep, color=col ? close > emaStep ? color.green : color.red : color.black, style=plot.style_line, linewidth=2, title='EMA (HTF)')


//STRATEGY CONDITION--------------
var bool isBreakeout = false
var bool isBreakedown = false

// Logic for Buy signal
Condndition_Buy1 = close > eema
Condndition_Buy2 = close > pvwap
Condndition_Buy3 = low <= eema
Condndition_Buy4 = low <= pvwap
Condndition_Buy5 = high[0]>=high[1] 

if Condndition_Buy1 and Condndition_Buy2 and Condndition_Buy3 and Condndition_Buy4 and Condndition_Buy5
    isBreakeout := true
    
    strategy.entry('Enter Long', strategy.long, stop=low, comment='Buy', alert_message = "CALL ENTRY")
    
    Buy_Profit_Range = high[0]-low[0]
    Book_Buy_Profit = Buy_Profit_Range*19.49
    strategy.exit('Exit Long', from_entry='Enter Long', profit=Book_Buy_Profit, stop=low[0])
else
    isBreakeout := false
    strategy.cancel(id='sell')

// 我在下面尝试了突破入场,但是订单是在前一个蜡烛高点 [1] 关闭后立即执行的,我需要我的入场点只有在高点 [1] 被突破后才被执行

Condndition_Buy5 = high[0]>=high[1]
pine-script-v5
© www.soinside.com 2019 - 2024. All rights reserved.