You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pine Script BTC抄底策略未按目标价执行买入订单求助

BTC抄底策略订单未执行问题排查求助

编写了以下Pine Script v5版本的BTC抄底策略,逻辑为当BTC价格跌至不同目标价位时挂出限价买单,但部分订单(如价格低于40000美元时的订单)未按目标价执行,仅部分订单正常生效。希望有人帮忙分析订单未执行的原因,排查逻辑问题并提供调试建议。

策略代码

//@version=5
strategy("BTC Buy on Dip", overlay=true)

start = timestamp(2022,1,1,0,0,0)
var float equity = 1000000
var initialPrice = 48000

if time > start and low < 45600
    // buy
    strategy.entry("1", strategy.long, qty=equity / 500 / 45600, limit = 45600)
    strategy.exit('sell', from_entry = "1", limit = (initialPrice - 45600) / 2 + 45600)

else if time > start and low < 43200
    // buy
    strategy.entry("2", strategy.long, qty=equity / 500 / 43200 * 1, limit = 43200)
    strategy.exit('sell', from_entry = "2", limit = (initialPrice - 43200) / 2 + 43200)

else if time > start and low < 40800
    // buy
    strategy.entry("3", strategy.long, qty=equity / 500 / 40800 * 2, limit = 40800)
    strategy.exit('sell', from_entry = "3", limit = (initialPrice - 40800) / 2 + 40800)

else if time > start and low < 38400
    // buy
    strategy.entry("4", strategy.long, qty=equity / 500 / 38400 * 4, limit = 38400)
    strategy.exit('sell', from_entry = "4", limit = (initialPrice - 38400) / 2 + 38400)

else if time > start and low < 36000
    // buy
    strategy.entry("5", strategy.long, qty=equity / 500 / 36000 * 8, limit = 36000)
    strategy.exit('sell', from_entry = "5", limit = (initialPrice - 36000) / 2 + 36000)

else if time > start and low < 33600
    // buy
    strategy.entry("6", strategy.long, qty=equity / 500 / 33600 * 16, limit = 33600)
    strategy.exit('sell', from_entry = "6", limit = (initialPrice - 33600) / 2 + 33600)

else if time > start and low < 31200
    // buy
    strategy.entry("8", strategy.long, qty=equity / 500 / 31200 * 32, limit = 31200)
    strategy.exit('sell', from_entry = "8", limit = (initialPrice - 31200) / 2 + 31200)

else if time > start and low < 28800
    // buy
    strategy.entry("9", strategy.long, qty=equity / 500 / 28800 * 64, limit = 28800)
    strategy.exit('sell', from_entry = "9", limit = (initialPrice - 28800) / 2 + 28800)

else if time > start and low < 26400
    // buy
    strategy.entry("105", strategy.long, qty=equity / 500 / 26400 * 128, limit = 26400)
    strategy.exit('sell', from_entry = "10", limit = (initialPrice - 26400) / 2 + 26400)

else if time > start and low < 24000
    // buy
    strategy.entry("11", strategy.long, qty=equity / 500 / 24000 * 256, limit = 24000)
    strategy.exit('sell', from_entry = "11", limit = (initialPrice - 24000) / 2 + 24000)

else if time > start and low < 21600
    // buy
    strategy.entry("12", strategy.long, qty=equity / 500 / 21600 * 512, limit = 21600)
    strategy.exit('sell', from_entry = "12", limit = (initialPrice - 21600) / 2 + 21600)

else if time > start and low < 19200
    // buy
    strategy.entry("13", strategy.long, qty=equity / 500 / 19200 * 1024, limit = 19200)
    strategy.exit('sell', from_entry = "13", limit = (initialPrice - 19200) / 2 + 19200)

订单执行情况截图

订单执行情况截图

感谢您的帮助!

内容的提问来源于stack exchange,提问作者Swa1n Suen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 03:44:56