策略。输入如果仅在下一个栏中满足条件
我正在制定策略,并且有以下问题。
垂直红线是进入短
的信号蜡烛水平虚线的信号蜡烛是所需的入口价格
我不想在信号栏上输入,所以我让Process_orders_on_close = false
我只想在下一个bar中输入贸易,如果价格输入停止价格在那里触发,不想等到价格才能集会5条然后击中我的条目
//@version=5
strategy("str demo", "str demo", overlay=true)
var float desired_entry_price = 0.0
var float entry_low = 0.0
var float entry_high = 0.0
var float c_entry_range = 0.0
var float position_avg_price = 0.0
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if shortCondition and strategy.position_size == 0
line.new(bar_index, close, bar_index, close + 1, xloc.bar_index, extend.both, color=color.new(color.red, 70) ) //vertical line
if shortCondition and strategy.position_size == 0
entry_low := low
entry_high := high
c_entry_range := entry_high - entry_low
desired_entry_price := entry_low - 10 * syminfo.mintick
strategy.entry("es", strategy.short, qty = 10, stop = desired_entry_price )
position_avg_price := strategy.position_avg_price
s_sl1 = entry_high
s_tp1 = entry_low - (c_entry_range * 2.5)
plot(desired_entry_price, style=plot.style_circles, color=color.new(color.red, 0) )
if strategy.position_size < 0
strategy.exit("x1", "es", qty_percent = 100, limit = s_tp1, stop = s_sl1)
I work on a strategy and i have the following problem.
vertical red line is the signal candle to enter short
horizontal dotted line is the desired entry price
i do not want to enter on the signal bar, so i let process_orders_on_close = false
i want to enter in trade only in the next bar if price entry stop price is triggered there, do not want to wait for price to rally ex 5 bars then hit my entry
//@version=5
strategy("str demo", "str demo", overlay=true)
var float desired_entry_price = 0.0
var float entry_low = 0.0
var float entry_high = 0.0
var float c_entry_range = 0.0
var float position_avg_price = 0.0
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if shortCondition and strategy.position_size == 0
line.new(bar_index, close, bar_index, close + 1, xloc.bar_index, extend.both, color=color.new(color.red, 70) ) //vertical line
if shortCondition and strategy.position_size == 0
entry_low := low
entry_high := high
c_entry_range := entry_high - entry_low
desired_entry_price := entry_low - 10 * syminfo.mintick
strategy.entry("es", strategy.short, qty = 10, stop = desired_entry_price )
position_avg_price := strategy.position_avg_price
s_sl1 = entry_high
s_tp1 = entry_low - (c_entry_range * 2.5)
plot(desired_entry_price, style=plot.style_circles, color=color.new(color.red, 0) )
if strategy.position_size < 0
strategy.exit("x1", "es", qty_percent = 100, limit = s_tp1, stop = s_sl1)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果满足条件并且在下一个条上没有条目,则可以取消待定订单。
只需使用
straging.cancel()
或straging.cancel_all()
函数。将其添加到脚本的末尾:You can cancel pending orders if the condition is met and there was no entry on the next bar.
Just use
strategy.cancel()
orstrategy.cancel_all()
function. Add this to the end of your script: