【发布时间】:2023-01-31 09:51:18
【问题描述】:
我正在制定一个小的长期策略。该策略在预定义的价格水平(按行设置)的收盘交叉点买入。我的目标是以交叉的确切价格和时间执行多头市价订单。我已经尝试了几种解决方案,目前我的脚本以准确的价格购买,但只在下一根蜡烛上执行订单。下面我留下代码。
//@version=5
strategy(title = '',
overlay = true,
calc_on_every_tick = true,
initial_capital = 1000,
commission_type = strategy.commission.percent,
commission_value = 0.03,
pyramiding = 1,
default_qty_value = 100,
default_qty_type = strategy.percent_of_equity,
process_orders_on_close = false,
close_entries_rule = 'ANY')
Line = input.price(0.00, "", group = "", confirm=true)
plot(Line)
Cond = ta.crossover(close, Line)
if Cond and strategy.position_size == 0
strategy.entry(id = "BUY LONG",
direction = strategy.long,
limit = Line,
qty = 100)
【问题讨论】:
标签: pine-script algorithmic-trading trading tradingview-api pine-script-v5