
이 전략은 가닥 크기를 기반으로 중요한 가격 움직임을 식별하고 거래한다. 구체적인 점수 마이너스, 거래 시간 창 및 매일 거래 수 제한을 설정하여 정밀한 통제를 수행한다. 이 전략은 특히 선물 시장에 최적화되어 있으며, 유동성이 높은 시간에 눈에 띄는 가격 변화를 잡을 수 있다.
이 전략의 핵심 논리는 각 줄무늬의 높고 낮은 점의 차이를 계산하여 (점수 단위로) 기본의 마이너스와 비교하는 것이다. 줄무늬가 크기가 마이너스를 초과하고 지정된 거래 시간 창 안에 있을 때 (미국 시간 7:00-9:15을 기본으로), 시스템은 줄무늬의 방향에 따라 다공간 거래 신호를 유발한다. 위험을 통제하기 위해, 전략은 하루에 한 번만 거래하는 것을 제한하고, 스톱 손실 지점을 설정한다.
이 전략은 정확한 점수 제어와 엄격한 시간 필터링을 통해 선물 거래에 대한 신뢰할 수 있는 거래 시스템을 제공합니다. 그것의 장점은 실행의 정확성과 위험 제어에 있습니다. 그러나 또한 거래자가 특정 품종과 시장 상황에 따라 매개 변수를 최적화해야 합니다. 제안된 최적화 방향을 통해 전략은 그것의 적응성과 안정성을 더욱 향상시킬 수 있습니다.
/*backtest
start: 2025-02-15 01:00:00
end: 2025-02-20 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © omnipadme
//@version=5
strategy("Futures Candle Size Strategy (Start Trading on Jan 1, 2025)", overlay=true)
// Input for candle size threshold in ticks
candleSizeThresholdTicks = input.float(25, title="Candle Size Threshold (Ticks)", minval=1)
// Input for take profit and stop loss in ticks
takeProfitTicks = input.float(50, title="Take Profit (Ticks)", minval=1)
stopLossTicks = input.float(40, title="Stop Loss (Ticks)", minval=1)
// Time filter for trading (e.g., 7:00 AM to 9:15 AM CST)
startHour = input.int(7, title="Start Hour (CST)", minval=0, maxval=23)
startMinute = input.int(0, title="Start Minute (CST)", minval=0, maxval=59)
endHour = input.int(9, title="End Hour (CST)", minval=0, maxval=23)
endMinute = input.int(15, title="End Minute (CST)", minval=0, maxval=59)
// Tick size of the instrument (e.g., ES = 0.25)
tickSize = syminfo.mintick
// Convert tick inputs to price levels
candleSizeThreshold = candleSizeThresholdTicks * tickSize
takeProfit = takeProfitTicks * tickSize
stopLoss = stopLossTicks * tickSize
// Time range calculation
startTime = timestamp("GMT-6", year(timenow), month(timenow), dayofmonth(timenow), startHour, startMinute)
endTime = timestamp("GMT-6", year(timenow), month(timenow), dayofmonth(timenow), endHour, endMinute)
inTimeRange = (time >= startTime and time <= endTime)
// Filter to start trading only from January 1, 2025
startTradingDate = timestamp("GMT-6", 2025, 1, 1, 0, 0)
isValidStartDate = time >= startTradingDate
// Calculate the candle size for the current candle
candleSize = math.abs(high - low)
// Track whether a trade has been executed for the day
var hasTradedToday = false
isNewDay = dayofweek != dayofweek[1] // Detect new day
// Reset `hasTradedToday` at the start of a new day
if isNewDay
hasTradedToday := false
// Trigger condition for futures trading (only if no trade has been executed today)
triggerCondition = isValidStartDate and inTimeRange and candleSize >= candleSizeThreshold and not hasTradedToday
// Entry logic: If condition is met, enter a trade
if triggerCondition
hasTradedToday := true // Mark as traded for the day
if close > open // Bullish candle
strategy.entry("Buy", strategy.long)
if close < open // Bearish candle
strategy.entry("Sell", strategy.short)
// Set take profit and stop loss
strategy.exit("Exit Long", from_entry="Buy", limit=close + takeProfit, stop=close - stopLoss)
strategy.exit("Exit Short", from_entry="Sell", limit=close - takeProfit, stop=close + stopLoss)
// Alerts for triggered condition
if triggerCondition
alert("Candle size is " + str.tostring(candleSizeThresholdTicks) + " ticks or greater. Trade initiated.", alert.freq_once_per_bar)
// Color the alert candle white
barcolor(triggerCondition ? color.white : na)
// Visual aids for backtesting
bgcolor(isValidStartDate and inTimeRange ? color.new(color.green, 90) : na, title="Time and Date Range Highlight")