Quantitative Trading Strategy Based on High Low Point Moving Averages
This strategy uses simple moving averages of high points and low points compared to current close price to determine entries and exits. It aims to capture price breakout signals from moving average crossovers to…
Overview
This strategy uses simple moving averages of high points and low points compared to current close price to determine entries and exits. It aims to capture price breakout signals from moving average crossovers to obtain early trend opportunities.
Strategy Logic
Calculate 4-period simple moving average of high prices.
Calculate 4-period simple moving average of low prices.
Go long when close price breaks above high point SMA.
Go short when close price breaks below low point SMA.
Use fixed stop loss and take profit for risk management.
Advantage Analysis
Uses simple indicators, easy to understand and implement.
Timely captures price breakout signals from SMA crossovers.
Can quickly filter out noise and identify trends.
Lightweight calculations reduce strategy overhead.
Suitable as base strategy for extensions.
Risk Analysis
Requires reasonable parameters to avoid oversensitivity.
Unable to handle risks from huge breakouts.
Possibilities of whipsaw losses in ranges.
Cannot automatically adjust stops and limits.
Hard to judge longer-term trend context.
Optimization Directions
Test different parameters for impact on signal quality.
Add filters to validate effectiveness of breakouts.
Incorporate trend analysis to avoid traps.
Develop dynamic stops and limits.
Optimize stops to improve win rate.
Test robustness across different timeframes.
Summary
This strategy uses simple indicators to gauge price momentum and provides a basic trend trading framework. With further improvements like parameter optimization and risk controls, the trading logic is highly extensible into a robust quant system. Overall an easy to use strategy suitable for beginners to start quant trading.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 2017 | Backtest Start Year |
| v_input_2 | 4 | Backtest Start Month |
| v_input_3 | true | Backtest Start Day |
| v_input_4 | 2017 | Backtest Stop Year |
| v_input_5 | 5 | Backtest Stop Month |
| v_input_6 | true | Backtest Stop Day |
| v_input_7 | true | Color Background? |
| v_input_8 | 4 | length |
| v_input_9 | false | displace |
Source Pine Script
/*backtest
start: 2023-09-11 00:00:00
end: 2023-09-13 00:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("HiLo", overlay=true)
// Testing a specific period
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(4, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testStopYear = input(2017, "Backtest Stop Year")
testStopMonth = input(5, "Backtest Stop Month")
testStopDay = input(1, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)
testPeriod() =>
time >= testPeriodStart and time <= testPeriodStop ? true : false
//HiLo Strategy
length = input(4, minval=0)
displace = input(0, minval=0)
highsma = sma(high, length)
lowsma = sma(low, length)
longCondition = close > highsma[displace]
if (longCondition)
strategy.entry("long", true)
shortCondition = close < lowsma[displace]
if (shortCondition)
strategy.entry("short", false)
// Exit seems with a problem. it keeps saying the order's limit (2000) was reached even if I back test it just for a day.
// If the two lines bellow are commented, then it it works. Anyone? Any idea what's wrong?
// strategy.exit("exit", "long", profit=10, loss=5)
// strategy.exit("exit", "short", profit=10, loss=5)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-19. 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-High-Low-Point-Moving-Averages.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.
Related specs
- 5 Day Moving Average Channel Breakout Strategy Combined With Mileage ConceptPine Script · Breakout · 1d
- Adaptive Bollinger Breakout with Moving Average Quantitative Strategy SystemPine Script · Breakout · 1h
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h
- Adaptive Trading Strategy Based on ADX IndicatorPine Script · Breakout · 1d
- Average Line Breakthrough StrategyPine Script · Breakout · 1d
- BB Breakout StrategyPine Script · Breakout · 1d