Overview
The "Advanced Time-Based Session Trading Strategy with Smart Reversal Logic" is a precise quantitative trading approach specifically designed for session trading within a 1-hour timeframe. The strategy leverages directional confirmation, pre-defined risk parameters, and limit orders that execute overnight to gain a market edge. At its core, the strategy compares the open price at 08:00 NY with the close at 18:00 NY to determine trading direction, applying intelligent reversal logic based on the previous day's trend to effectively avoid momentum exhaustion and capture corrective reversals. The strategy also implements a fully automated trading environment through user-defined stop-loss, take-profit settings, and risk control parameters.
Strategy Principles
The core principles of this strategy are based on time-specific price relationship analysis and smart reversal logic:
Direction Confirmation Mechanism: At 18:00 NY each day, the system compares the open at 08:00 with the close at 18:00. If the price direction of the current day matches the previous day, the strategy reverses the signal; if the directions differ, it maintains the current day's trend direction. This logic aims to avoid trend exhaustion and capture price corrections.
Entry Point Definition: Based on the confirmed direction, the system automatically sets entry points:
- For BUY signals: The day's low is used as the entry point
- For SELL signals: The day's high is used as the entry point
The system sets stop-loss and take-profit levels based on user-defined pips (default: SL = 18 pips, TP = 54 pips, risk-reward ratio 1:3).
Time-Limited Entry Execution: Orders are sent after 18:00 NY and can be triggered at any time between 18:00 and 08:00 NY the following day. If the entry point is not touched before 08:00 NY, the order is automatically canceled.
Manual Close Feature: If a trade remains open at the configured time (default 09:00 NY), the system closes all positions, simulating realistic intraday exit scenarios.
Risk-Based Position Sizing: Position size is dynamically calculated based on account size, risk percentage, and stop-loss distance, ensuring consistent risk exposure regardless of market volatility.
Strategy Advantages
Through deep analysis of the code, this strategy demonstrates the following significant advantages:
Time-Precise Trading Execution: The strategy utilizes specific time points (08:00 NY and 18:00 NY) for decision-making and execution, ensuring opportunities are captured at key market moments. This time-based approach reduces noise trading and increases the predictability of trades.
Smart Reversal Logic: By comparing price directions across consecutive days, the strategy can identify potential trend exhaustion points and reverse direction accordingly. This approach helps avoid chasing over-extended trends and improves entry precision.
Integrated Risk Management: The strategy incorporates comprehensive risk management features, including:
- Predefined stop-loss/take-profit settings
- Dynamic position sizing based on account size and risk tolerance
- Time-based automatic position closing mechanism
Limit Order Advantage: Using limit orders rather than market orders ensures trade execution at more favorable prices, reduces slippage, and avoids entries under unfavorable conditions.
Fully Automated Operation: Once set up, the strategy can run completely automated, eliminating the need for constant monitoring and reducing emotional interference and human error.
Strategy Risks
Despite its sophisticated design, the strategy carries the following risks:
Missed Trading Opportunities: Since entry points are based on day highs/lows with time constraints, the strategy may miss trading opportunities when prices don't reach the set levels. This is particularly common in low-volatility environments.
Reversal Logic Failure Risk: In strongly trending markets, the reversal logic based on directional similarity may lead to premature counter-trend trading, increasing the risk of losses.
Time Dependency: The strategy heavily relies on specific time points (NY time), which may reduce effectiveness in different markets or during irregular trading hours.
Fixed Stop-Loss Risk: Using fixed pip values for stop-losses may not adapt to all market conditions, especially when volatility suddenly increases.
Solution methods:
- Implement adaptive stop-losses that adjust based on current market volatility
- Add additional filtering conditions to avoid trading during extreme market conditions
- Introduce multi-timeframe confirmation to enhance entry signal quality
- Consider reduced position sizing during high-volatility periods
Optimization Directions
The strategy can be optimized through the following approaches:
Dynamic Stop-Loss/Take-Profit Levels: Currently, the strategy uses fixed pip values for stop-loss and take-profit. This could be improved by implementing levels based on ATR or volatility percentages to better adapt to different market conditions. The reason for this is that market volatility changes over time, and fixed pip values may be too small during high-volatility periods and too large during low-volatility periods.
Add Trend Filters: Introduce trend indicators (such as moving average crossovers or ADX) as additional confirmation, only trading in favorable trend environments. This would reduce false signals in ranging markets and improve overall win rates.
Optimize Time Windows: Through backtesting different time point combinations (not limited to 08:00 and 18:00), find optimal time windows for specific markets. Different financial instruments may exhibit unique behavioral patterns at different times.
Incorporate Multi-Period Confirmation: Verify 1-hour signals by checking the direction of higher timeframes (such as 4-hour or daily), ensuring trades align with larger trends. This approach can reduce the risk of counter-trend trading.
Implement Partial Profit Mechanism: Add functionality to partially close positions when specific profit levels are reached, locking in some profits while allowing the remaining position to continue running. This can improve overall profit stability while maintaining higher return potential.
Summary
The "Advanced Time-Based Session Trading Strategy with Smart Reversal Logic" is a meticulously designed quantitative trading system that combines time-specific decision points, intelligent direction confirmation, and comprehensive risk management. By analyzing price relationships at key time points (08:00 and 18:00 NY) and applying smart reversal logic, the strategy effectively identifies potential trend exhaustion points and corrective reversal opportunities.
The strategy's limit order mechanism ensures more favorable entry prices, while predefined risk parameters and dynamic position sizing provide consistent risk control. Although some inherent risks exist, such as missed trading opportunities and reversal logic failures in certain market conditions, these can be mitigated through the suggested optimization directions.
By implementing dynamic stop-loss/take-profit levels, adding trend filters, optimizing time windows, incorporating multi-period confirmation, and partial profit mechanisms, the strategy has the potential to further enhance its performance and adaptability. Overall, this is a well-structured, logically sound trading system particularly suitable for traders seeking automation and discipline in intraday trading.
Strategy source code
/*backtest
start: 2024-06-27 00:00:00
end: 2025-06-25 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":50000000}]
*/
//@version=6
strategy("LANZ Strategy 1.0 [Backtest]", overlay=true, default_qty_type=strategy.cash, default_qty_value=100)
// === TIMEFRAME RESTRICTION ===
if timeframe.period != "60"
runtime.error("π« LANZ Strategy 1.0 is only available on the 1h timeframe.")
// === INPUTS ===
accountSizeUSD = input.int(100000, title="Account #1 - Capital ($)", minval=1, group="πΈ Main Account Management")
riskPercent = input.float(1.0, title="Account #1 - Risk (%)", minval=0.1, maxval=100, group="πΈ Main Account Management")
slPipsInput = input.int(18, title="Stop Loss (pips)", minval=1, group="π Risk Settings")
tpPipsInput = input.int(54, title="Take Profit (pips)", minval=1, group="π Risk Settings")
manualCloseHour = input.int(9, title="Hora de Cierre Manual (NY)", minval=0, maxval=23, group="π Cierre Manual")
// === GLOBALS ===
pipSize = syminfo.mintick * 10
var float openAt0800 = na
var float closeAt1800 = na
var int priceDirection = na
var int prevPriceDirection = na
var int todayPriceDirection = na
var int finalSignalDirection = na
var float baseLevel = na
var float baseSL = na
var float baseTP = na
var bool orderSent = false
// === KEY TIMES ===
is0800 = (hour(time, "America/New_York") == 8 and minute(time, "America/New_York") == 0)
is1800 = (hour(time, "America/New_York") == 18 and minute(time, "America/New_York") == 0)
nyHour = hour(time, "America/New_York")
nyMinute = minute(time, "America/New_York")
entryWindow = (nyHour >= 18 or nyHour < 8)
cutoffPassed = not entryWindow
isManualClose = (nyHour == manualCloseHour and nyMinute == 0)
// === CAPTURE OPEN AND CLOSE ===
if is0800
openAt0800 := open
if is1800
closeAt1800 := close
priceDirection := closeAt1800 > openAt0800 ? 1 : closeAt1800 < openAt0800 ? -1 : 0
prevPriceDirection := todayPriceDirection
todayPriceDirection := priceDirection
coinciden = priceDirection == prevPriceDirection and not na(prevPriceDirection)
finalSignalDirection := coinciden ? priceDirection : -1 * priceDirection
fibRange = high - low
baseLevel := finalSignalDirection == -1 ? low : high
baseSL := finalSignalDirection == -1 ? baseLevel - slPipsInput * pipSize : baseLevel + slPipsInput * pipSize
baseTP := finalSignalDirection == -1 ? baseLevel + tpPipsInput * pipSize : baseLevel - tpPipsInput * pipSize
orderSent := false
// === LIMIT ORDER SENDING (AT 19:00 AND FOLLOWING IF NOT YET TOUCHED) ===
canPlaceOrder = not orderSent and strategy.opentrades == 0 and entryWindow
if canPlaceOrder
slPips = math.abs(baseLevel - baseSL) / pipSize
riskUSD = accountSizeUSD * (riskPercent / 100)
qty = slPips > 0 ? (riskUSD / (slPips * 10)) : na
if not na(qty)
isLong = finalSignalDirection == -1
if isLong
strategy.entry("BUY", strategy.long, qty=qty, limit=baseLevel)
strategy.exit("TP/SL BUY", from_entry="BUY", stop=baseSL, limit=baseTP)
else
strategy.entry("SELL", strategy.short, qty=qty, limit=baseLevel)
strategy.exit("TP/SL SELL", from_entry="SELL", stop=baseSL, limit=baseTP)
orderSent := true
// === CANCEL IF NO EP TOUCHED BEFORE 08:00 NY ===
if cutoffPassed and strategy.opentrades == 0 and orderSent
strategy.cancel("BUY")
strategy.cancel("SELL")
orderSent := false
// === MANUAL CLOSING AT HH:00 NY CONFIGURABLE ===
if strategy.opentrades > 0 and isManualClose
strategy.close("BUY")
strategy.close("SELL")
Strategy parameters
The original address: Advanced Time-Based Session Trading Strategy with Smart Reversal Logic
Top comments (1)
Time-based trading with smart reversal logic? Finally, something smarter than my 3AM 'this is the bottom!' trades! If this strategy can actually tell when a reversal is coming (instead of just pretending like I do), I might finally stop buying the top. Bonus points if it works during lunch breaks too!