
이 전략은 30분 K 선에 기반한 양방향 거래 시스템으로 가격 변동의 폭을 모니터링하여 거래 기회를 찾습니다. 전략의 핵심은 포인트 절벽을 설정하여 큰 변동성을 식별하고, 브레이크 확인 후 해당 방향으로 거래하는 것입니다. 전략에는 엄격한 시간 관리, 스톱 손실 및 거래 관리 메커니즘이 포함되어 있습니다.
전략은 유효한 거래 신호를 식별하기 위해 여러 가지 필터링 메커니즘을 사용합니다. 첫째, 전략은 매 30분마다 K 라인 종료 시 엔티티의 변동 범위를 계산합니다. 변동이 기본 경계를 초과하면 잠재적인 거래 기회로 표시됩니다. 거래의 유효성을 보장하기 위해, 전략은 추가적인 완충 지점을 설정합니다. 가격이 이 완충 영역을 돌파 할 때만 실제 거래 신호를 유발합니다. 전략은 동시에 다중 공백 쌍방향 거래를 실현합니다.
이것은 완전하고 논리적으로 명확하게 설계된 자동화 거래 전략이다. 엄격한 조건 필터링과 위험 통제를 통해 전략은 더 나은 실용성을 가지고 있다. 그러나 여전히 실내에서 충분한 테스트와 최적화가 필요하며, 특히 파라미터 설정과 위험 통제에 대해서는 실제 시장 상황에 따라 조정해야 한다. 전략의 성공적인 운영은 안정적인 시장 환경과 적절한 파라미터 구성이 필요하며, 실내에서 사용하기 전에 충분한 재검토를 수행하는 것이 좋습니다.
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Big Candle Breakout Strategy Both Side", overlay=true)
// Input for the point move threshold
point_move_in = input.int(100, title="Point Move Threshold")
point_target = input.int(100, title="Point Target")
point_stoploss = input.int(100, title="Point Stop Loss")
point_buffer = input.int(5, title="Point Buffer")
point_move = point_buffer + point_move_in
// Define the start and end times for trading
start_hour = 9
start_minute = 15
end_hour = 14
end_minute = 30
// Function to check if the current time is within the allowed trading window
in_time_range = (hour(time('30')) > start_hour or (hour(time('30')) == start_hour and minute(time('30')) >= start_minute)) and (hour(time('30')) < end_hour or (hour(time('30')) == end_hour and minute(time('30')) <= end_minute))
// Retrieve the open, high, low, and close prices of 30-minute candles
open_30m = request.security(syminfo.tickerid, "30", open)
high_30m = request.security(syminfo.tickerid, "30", high)
low_30m = request.security(syminfo.tickerid, "30", low)
close_30m = request.security(syminfo.tickerid, "30", close)
// Calculate the range of the candle
candle_range_long = (close_30m - open_30m)
candle_range_short = (open_30m - close_30m)
// Determine if the candle meets the criteria to be marked
big_candle_long = candle_range_long >= point_move_in
big_candle_short = candle_range_short >= point_move_in
// Variables to store the state of the trade
var float long_entry_price = na
var float long_target_price = na
var float long_stop_loss_price = na
var float short_entry_price = na
var float short_target_price = na
var float short_stop_loss_price = na
// Check if there are no active trades
no_active_trades = (strategy.opentrades == 0)
// Long entry condition
if (big_candle_long and na(long_entry_price) and in_time_range and no_active_trades)
long_entry_price := high_30m+point_buffer
long_target_price := long_entry_price + point_target
long_stop_loss_price := long_entry_price - point_stoploss
strategy.entry("Buy", strategy.long, stop=long_entry_price, limit=long_target_price)
plot(long_entry_price, style=plot.style_linebr, color=color.blue, linewidth=2, title="Entry Price")
plot(long_target_price, style=plot.style_linebr, color=color.green, linewidth=2, title="Target Price")
plot(long_stop_loss_price, style=plot.style_linebr, color=color.red, linewidth=2, title="Stop Loss Price")
// Short entry condition
if (big_candle_short and na(short_entry_price) and in_time_range and no_active_trades)
short_entry_price := low_30m - point_buffer
short_target_price := short_entry_price - point_target
short_stop_loss_price := short_entry_price + point_stoploss
strategy.entry("Sell", strategy.short, stop=short_entry_price, limit=short_target_price)
plot(short_entry_price, style=plot.style_linebr, color=color.blue, linewidth=2, title="Short Entry Price")
plot(short_target_price, style=plot.style_linebr, color=color.green, linewidth=2, title="Short Target Price")
plot(short_stop_loss_price, style=plot.style_linebr, color=color.red, linewidth=2, title="Short Stop Loss Price")
// Long exit conditions
if (not na(long_entry_price))
strategy.exit("Long Exit", from_entry="Buy", limit=long_target_price, stop=long_stop_loss_price)
// Short exit conditions
if (not na(short_entry_price))
strategy.exit("Short Exit", from_entry="Sell", limit=short_target_price, stop=short_stop_loss_price)
// Reset trade status
if (strategy.position_size == 0)
long_entry_price := na
long_target_price := na
long_stop_loss_price := na
short_entry_price := na
short_target_price := na
short_stop_loss_price := na
// Plot the big candle and entry/exit levels
plotshape(series=big_candle_long, location=location.abovebar, style=shape.circle, color=color.green)
plotshape(series=big_candle_short, location=location.abovebar, style=shape.circle, color=color.red)
//plot(long_entry_price, style=plot.style_stepline, color=color.blue, linewidth=2, title="Entry Price")
//plot(long_target_price, style=plot.style_stepline, color=color.green, linewidth=2, title="Target Price")
//plot(long_stop_loss_price, style=plot.style_stepline, color=color.red, linewidth=2, title="Stop Loss Price")