
The Hourly Open-Close Price Differential Smart Comparison Quantitative Trading System is a price action-based quantitative trading strategy that focuses on capturing momentum shifts between the current period’s open price and the previous period’s close price. The strategy identifies potential upward price trends by comparing the current period’s opening price with the previous period’s closing price, establishing long positions when specific conditions are met. The system incorporates a fixed percentage profit target (3%), automatically closing positions when the target price is reached to secure profits. The core advantage of this strategy lies in its simplicity and executability, making it an ideal choice for short-term traders and intraday traders.
The Hourly Open-Close Price Differential strategy is based on market price action and momentum theory. Specifically, the strategy follows this logical process:
Buy Condition Evaluation: The strategy first checks if the current period’s opening price is higher than the previous period’s closing price (open > close[1]), while ensuring no current position exists (strategy.position_size == 0). When both conditions are satisfied, the system identifies a buy signal.
Buy Order Execution: When the buy condition is met, the system executes a long entry through the strategy.entry(“Buy”, strategy.long) command. Simultaneously, it marks the buy point on the price chart, displaying the specific entry price.
Profit Target Setting: After entry, the system immediately calculates the profit target price, set at 103% of the purchase price (targetPrice = strategy.position_avg_price * 1.03), equivalent to a 3% take-profit level.
Exit Condition Monitoring: The strategy continuously monitors the current market price, and once the closing price reaches or exceeds the target price (close >= targetPrice) while holding a long position (strategy.position_size > 0), the system automatically executes the closing operation.
Trade Visualization: To intuitively display trading activity, the strategy plots buy and sell signals on the chart, allowing traders to clearly track strategy execution.
This strategy leverages the principle of price momentum continuity, where an opening price higher than the previous period’s closing price often indicates market upward momentum that may continue in the short term, creating profit opportunities.
Through deep analysis of the strategy’s code implementation, the following significant advantages can be summarized:
Clear and Concise Entry Logic: The strategy uses a simple and easy-to-understand price comparison as the entry signal, without relying on complex indicators or parameter settings, reducing the risk of overfitting.
Defined Profit Targets: The fixed 3% take-profit setting provides clear profit expectations, helping to maintain a good risk-reward ratio.
Automated Execution: The strategy is fully automated from signal identification to entry and exit, reducing human intervention and emotional decision-making.
Integrated Fund Management: Through default_qty_type=strategy.percent_of_equity and default_qty_value=100 parameter settings, the strategy invests 100% of the account value in each trade, simplifying fund management.
Visualized Trading Records: By marking buy and sell points on the chart, traders can visually review strategy execution, facilitating subsequent analysis and strategy adjustments.
Prevention of Duplicate Entries: By checking the current position status (strategy.position_size == 0), the strategy ensures no re-entry when a position already exists, avoiding unnecessary risk accumulation.
Suitability for High Liquidity Markets: The strategy operates on an hourly timeframe, particularly suitable for high liquidity market environments, ensuring the executability of trading signals.
Despite the strategy’s concise design, there are several potential risks:
Lack of Stop-Loss Mechanism: The current strategy only sets take-profit conditions without a clear stop-loss mechanism. If the market moves unfavorably, it could lead to significant losses. It is recommended to add stop-loss conditions, such as time-based or price-based stop-loss settings.
Limitations of Fixed Percentage Targets: The fixed 3% take-profit target may not adapt to different market environments and volatilities. It may be too high in low-volatility markets and too low in high-volatility markets.
Vulnerability of Single Entry Condition: Relying solely on the comparison between opening price and previous period’s closing price as an entry signal may lead to misleading signals when market noise is significant.
Lack of Trend Filtering: The strategy does not consider the broader market trend environment and may issue buy signals even in downtrends, increasing the risk of counter-trend trading.
Fund Management Risk: The default uses 100% of account equity for trading without adjusting position size based on market volatility or risk level, potentially leading to excessive risk concentration.
Timeframe Dependence: The strategy focuses on the hourly period and may fail to capture price fluctuations in shorter timeframes or longer-term market trends.
Backtest Bias Risk: Using the closing price as a trigger for closing positions may lead to execution slippage in actual trading, as one might need to wait for closing price confirmation before execution.
Based on in-depth analysis of the strategy code, we can propose the following optimization directions:
Introduce Stop-Loss Mechanism: Add time-based or price-based stop-loss conditions, such as setting maximum holding time or ATR-based (Average True Range) stop-loss levels to limit maximum loss per trade.
Dynamic Profit Targets: Change the fixed 3% take-profit target to a volatility-based dynamic target, such as using multiples of ATR as the basis for target price calculation.
Add Entry Filtering Conditions: Combine other technical indicators (such as moving averages, RSI, or MACD) as confirmation signals to improve the quality and reliability of entry signals.
Add Trend Direction Filtering: Introduce long-term moving averages or other trend indicators to ensure entries only when the overall trend direction is consistent.
Optimize Fund Management: Implement dynamic position management, adjusting the proportion of funds for each trade based on market conditions, account equity, and risk levels.
Multi-Timeframe Analysis: Integrate market analysis results from higher timeframes, executing trades only when trends across different timeframes align.
Introduce Time Filtering: Add trading time window restrictions to avoid market periods with too low or too high volatility.
Optimize Execution Logic: Consider using limit orders instead of market orders to execute trades, reducing slippage and execution costs.
Implementing these optimization directions will help improve the strategy’s robustness and adaptability, enabling it to maintain relatively stable performance across different market environments.
The Hourly Open-Close Price Differential Smart Comparison Quantitative Trading System is a concise and practical trading system that captures short-term price momentum by utilizing the relationship between opening prices and previous period closing prices. With its simple logic and clear execution rules, the strategy provides traders with an easy-to-understand and implement trading method. Despite some potential risks, such as the lack of a stop-loss mechanism and limitations of single entry conditions, the strategy’s robustness and profit potential can be significantly enhanced through optimizations like introducing stop-loss strategies, dynamic profit target settings, and additional entry filtering conditions.
This strategy is particularly suitable for short-term traders and day traders, especially in markets with moderate volatility. Through continuous backtesting and optimization, traders can adjust parameters according to specific markets and personal risk preferences to further improve strategy performance. Ultimately, whether as an independent trading system or as a component of more complex trading strategies, the Hourly Open-Close Price Differential strategy demonstrates the potential and value of quantitative trading methods based on price action analysis.
/*backtest
start: 2025-03-02 00:00:00
end: 2025-04-01 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BNB_USDT"}]
*/
//@version=6
strategy("1 Hour Open vs Close Buy Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Define the buy condition: current open is higher than the previous close
buyCondition = open > close[1] and strategy.position_size == 0 // Only buy if there is no active position
// Execute the buy order and plot buy price
if (buyCondition)
strategy.entry("Buy", strategy.long)
label.new(x=bar_index, y=low, text="Buy at: " + str.tostring(open), style=label.style_label_up, color=color.green, size=size.normal, textcolor=color.white)
// Define the sell condition based on 3% profit target from the buy price
targetPrice = strategy.position_avg_price * 1.03
// Check if the current price has reached the target price and close the position
if (strategy.position_size > 0 and close >= targetPrice)
strategy.close("Buy")
label.new(x=bar_index, y=high, text="Sell at: " + str.tostring(close), style=label.style_label_down, color=color.red, size=size.normal, textcolor=color.white)
// Plotting to visualize entries and exits on the chart
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="Buy")
plotshape(series=(strategy.position_size > 0 and close >= targetPrice), location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell")