Quantitative Trading Strategy Based on Daily Close Price Comparison
This strategy is called "Daily Close Price Comparison Strategy". It is a quantitative trading strategy that makes trading decisions based on daily close prices. The strategy generates trading signals by calculating…

Overview
This strategy is called "Daily Close Price Comparison Strategy". It is a quantitative trading strategy that makes trading decisions based on daily close prices. The strategy generates trading signals by calculating the difference between the current daily close price and the previous daily close price. When the difference exceeds a set threshold, buy or sell orders are executed.
Strategy Logic
The core logic of this strategy is to compare the close prices between the current candlestick/bar and the previous one. Specifically:
- Calculate the difference between the current daily close price and the previous daily close price (today - yesterday)
- Calculate the ratio between the difference and yesterday's close price (difference / yesterday's close)
- If the ratio is greater than the set positive threshold, a buy signal is generated. If the ratio is less than the set negative threshold, a sell signal is generated.
- Enter long or short positions according to the signals
The strategy does not set stop loss or take profit conditions, and relies on the threshold-triggered signals for entry and exit.
Advantage Analysis
- Simple logic, easy to understand, suitable for quant trading beginners
- Only relies on daily close prices, avoids over-frequent trading
- Trading frequency can be controlled by adjusting the threshold
Risk Analysis
- No stop loss, unable to control single trade loss
- May generate consecutive trading signals resulting in over trading
- Drawdown may be large, cannot control overall loss well
Optimization Directions
- Add stop loss logic to control single trade loss
- Limit number of entries to avoid over trading
- Optimize parameters to find optimal trading frequency
Conclusion
This strategy generates trading signals by comparing daily close prices. The logic is simple and suitable for beginners to learn. But it contains certain risks and needs further optimization for live trading.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | false | Price Difference Threshold correct results |
Source Pine Script
/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("Daily Close Comparison Strategy (by ChartArt) correct results", shorttitle="CA_-_Daily_Close_Strat", overlay=false)
// ChartArt's Daily Close Comparison Strategy
//
// Version 1.0
// Idea by ChartArt on February 28, 2016.
//
// This strategy is equal to the very
// popular "ANN Strategy" coded by sirolf2009,
// but without the Artificial Neural Network (ANN).
//
// Main difference besides stripping out the ANN
// is that I use close prices instead of OHLC4 prices.
// And the default threshold is set to 0 instead of 0.0014
// with a step of 0.001 instead of 0.0001.
//
// This strategy goes long if the close of the current day
// is larger than the close price of the last day.
// If the inverse logic is true, the strategy
// goes short (last close larger current close).
//
// This simple strategy does not have any
// stop loss or take profit money management logic.
//
// List of my work:
// https://www.tradingview.com/u/ChartArt/
//
// __ __ ___ __ ___
// / ` |__| /\ |__) | /\ |__) |
// \__, | | /~~\ | \ | /~~\ | \ |
//
//
threshold = input(title="Price Difference Threshold correct results", type=float, defval=0, step=0.004)
getDiff() =>
yesterday=request.security(syminfo.tickerid, 'D', close[1])
today=close
delta=today-yesterday
percentage=delta/yesterday
closeDiff = getDiff()
buying = closeDiff > threshold ? true : closeDiff < -threshold ? false : buying[1]
hline(0, title="zero line")
bgcolor(buying ? green : red, transp=25)
plot(closeDiff, color=silver, style=area, transp=75)
plot(closeDiff, color=aqua, title="prediction")
longCondition = buying
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = buying != true
if (shortCondition)
strategy.entry("Short", strategy.short)Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-21. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Quantitative-Trading-Strategy-Based-on-Daily-Close-Price-Comparison.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.