
이것은 1분 K 선의 종결 방향에 기초한 고주파 거래의 전략이다. 전략은 K 선의 종결 가격과 개시 가격의 관계를 판단하여 시장의 움직임을 결정하고, 보잉 K 선이 형성된 후에 더하고, 하향 K 선이 형성된 후에 공백한다. 전략은 고정된 포지션 시간을 채택하고, 다음 K 선의 종결시 포지션을 평정하고, 하루 최대 거래 수에 제한을 두고, 위험을 제어한다.
전략의 핵심 논리는 K선으로 종결 방향을 판단하는 것입니다.
이 전략은 간단한 가격 행동 분석을 통해 단기 시장 기회를 잡기 위해 K선 종결 방향에 기반한 고주파 거래 시스템입니다. 전략의 장점은 논리적으로 간단하고, 지주 기간이 짧고, 위험이 통제 가능하지만, 동시에 거래 비용과 가짜 돌파구와 같은 과제에 직면합니다. 전략의 안정성과 수익성은 더 많은 기술적 지표와 최적화 프로그램을 도입함으로써 더욱 향상 될 것으로 예상됩니다.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-12-10 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Candle Close Strategy", overlay=true)
// Define conditions for bullish and bearish candlesticks
isBullish = close > open
isBearish = close < open
// Track the number of bars since the trade was opened and the number of trades per day
var int barsSinceTrade = na
var int tradesToday = 0
// Define a fixed position size for testing
fixedPositionSize = 1
// Entry condition: buy after the close of a bullish candlestick
if (isBullish and tradesToday < 200) // Limit to 200 trades per day
strategy.entry("Buy", strategy.long, qty=fixedPositionSize)
barsSinceTrade := 0
tradesToday := tradesToday + 1
// Entry condition: sell after the close of a bearish candlestick
if (isBearish and tradesToday < 200) // Limit to 200 trades per day
strategy.entry("Sell", strategy.short, qty=fixedPositionSize)
barsSinceTrade := 0
tradesToday := tradesToday + 1
// Update barsSinceTrade if a trade is open
if (strategy.opentrades > 0)
barsSinceTrade := nz(barsSinceTrade) + 1
// Reset tradesToday at the start of a new day
if (dayofmonth != dayofmonth[1])
tradesToday := 0
// Exit condition: close the trade after the next candlestick closes
if (barsSinceTrade == 2)
strategy.close("Buy")
strategy.close("Sell")
// Plot bullish and bearish conditions
plotshape(series=isBullish, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=isBearish, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Plot the candlesticks
plotcandle(open, high, low, close, title="Candlesticks")