大家好, 我在交易视图中遇到一个奇怪的问题,即如果今天的条件为真,并且由于价格从未达到极限价格而没有触发定单,则条件仍然成立,并且如果价格达到极限价格,则在未来几天触发交易< / em>
我的代码所做的是检查一天中前两个15分钟蜡烛的高点和低点,如果第二个蜡烛的高点大于第一个蜡烛,则在第二个蜡烛高点突破时走多头:
strategy("high break", overlay=true)
locHigh = 0.0
locLow = 0.0
locHighs = 0.0
locLows = 0.0
h = security(syminfo.tickerid, "15", high, lookahead=true)
l = security(syminfo.tickerid, "15", low, lookahead=true)
ha = security(syminfo.tickerid, "15", high, lookahead=true)
la = security(syminfo.tickerid, "15", low, lookahead=true)
if hour == 9 and minute == 15
locHigh := h
locLow := l
else
locHigh := locHigh[1]
locLow := locLow[1]
if hour == 9 and minute == 30
locHighs := ha
locLows := la
else
locHighs := locHighs[1]
locLows := locLows[1]
plot(locLow, color = color.green)
plot(locHigh, color = color.green)
long_entry = locHighs
qty_long = 1000000/locHighs
newDay = (dayofweek != dayofweek[1])
t = time(timeframe.period, "0930-1500")
session_open = na(t) ? false : true
longCondition = locHighs > locHigh and locLows > locLow and session_open
strategy.entry("long", strategy.long, qty = qty_long, stop = locHighs, when = longCondition and strategy.position_size == 0)
strategy.risk.max_intraday_filled_orders(2)
strategy.exit ("Exit long","long",stop =locLows)
if not (session_open)
strategy.close("long")
是否有一种方法可以将条件限制为仅盘中?就像在条件为真时获取日期,而仅在条件为真日期与今天相同时才执行。
我还附上一张图片,以使您更好地理解:https://ibb.co/8mpp59R 谢谢!!