Name
基于信噪比和均线的量化交易策略Signal-to-Noise-Moving-Average-Trading-Strategy-Based-on-Quantitative-Trading
Author
ChaoZhang
Strategy Description
信噪比均线交易策略(Signal-to-Noise Moving Average Trading Strategy)
该策略通过计算一定周期内的信噪比,再结合均线交易信号,实现量化交易。其基本思路是:
- 计算一定周期(可设定)的信噪比
- 对信噪比应用均线平滑
- 比较当前信噪比与均线值,产生交易信号
- 根据交易信号做多头或空头
- 信噪比(Signal to Noise Ratio)的计算公式为:StN = -10*log(Σ(1/close)/n) 其中n为周期长度
- 对信噪比应用简单移动平均(SMA)得到平滑信噪比
- 比较当前信噪比StN与平滑信噪比SMAStN: (1) 如果SMAStN > StN,做空 (2) 如果SMAStN < StN,做多 (3) 否则清仓
该策略主要有以下优势:
- 信噪比能判断市场波动和风险,SMA有去噪功能
- 结合信噪比判断市场风险与SMA产生交易信号,运用不同指标优势
- 可设定参数调整策略,适应不同市场情况
- 可Stdout信号指示做多做空,直观判断市场特征
该策略也存在一些风险:
- 信噪比与均线交叉判断存在错位风险
- 周期设定不当可能导致虚假信号
- 做空机会相对少,可通过参数调整优化
- 突发事件导致剧烈波动,可能触发止损
风险解决:
- 调整均线参数,避免平滑过度
- 优化周期参数,测试不同市场适应性
- 调整做空条件,提供更多做空机会
- 设置止损以控制最大损失
该策略可以从以下方面进行优化:
- 测试更多类型均线的搭配使用
- 增加止损机制控制风险
- 增加仓位管理,根据波动调整仓位
- 结合更多因子判断,提高策略稳定性
- 使用机器学习方法自动优化参数
本策略通过信噪比判断市场波动风险,并利用均线产生交易信号,实现量化交易。相比单一技术指标,本策略整合信噪比与SMA各自的优势,在控制风险的同时提高稳定性。通过参数优化与机器学习等方式,本策略有很大的改进空间,是一种可靠、有效的量化交易策略。
||
Signal-to-Noise Moving Average Trading Strategy
This strategy realizes quantitative trading by calculating the signal-to-noise ratio over a certain period and combining it with moving average trading signals. The basic idea is:
- Calculate the signal-to-noise ratio over a certain period (adjustable)
- Apply moving average to smooth the signal-to-noise ratio
- Compare current signal-to-noise ratio with moving average value to generate trading signals
- Long or short based on trading signals
- The formula for calculating signal-to-noise ratio (StN) is: StN = -10*log(Σ(1/close)/n), where n is the length of the period
- Apply Simple Moving Average (SMA) to the signal-to-noise ratio to obtain smoothed StN
- Compare current StN with smoothed SMAStN: (1) If SMAStN > StN, go short (2) If SMAStN < StN, go long (3) Otherwise, close position
The main advantages of this strategy are:
- StN can judge market fluctuation and risk, SMA has noise reduction capability
- Combining StN to judge market risk and SMA to generate trading signals makes use of the advantages of different indicators
- Adjustable parameters to adapt to different market conditions
- Stdout signals directly indicate long or short, intuitive judgment of market characteristics
There are also some risks with this strategy:
- Crossing judgment between StN and MA exists deviation risk
- Improper period settings may cause false signals
- Relative fewer short opportunities, optimizable via parameter adjustment
- Extreme fluctuations caused by black swan events may trigger stop loss
Solutions:
- Adjust MA parameters to avoid over-smoothing
- Optimize period parameters and test adaptability in different markets
- Adjust short conditions to provide more short opportunities
- Set stop loss to control maximum losses
The strategy can be optimized in the following ways:
- Test combination of more types of moving averages
- Add stop loss mechanism to control risks
- Add position management, adjust positions based on fluctuations
- Incorporate more factors to improve stability
- Use machine learning methods to automatically optimize parameters
This strategy realizes quantitative trading by judging market risk via signal-to-noise ratio and generating trading signals from moving average. Compared to single technical indicators, this strategy integrates the advantages of both StN and SMA to improve stability while controlling risks. With parameter optimization and machine learning, this strategy has great potential for improvement and is a reliable and effective quantitative trading strategy.
[/trans]
Strategy Arguments
Argument | Default | Description |
---|---|---|
v_input_1 | 21 | Days |
v_input_2 | 7 | Smooth |
v_input_3 | false | Trade reverse |
Source (PineScript)
/*backtest
start: 2023-12-25 00:00:00
end: 2023-12-29 10:00:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HPotter 05/01/2021
// The signal-to-noise (S/N) ratio.
// And Simple Moving Average.
// Thank you for idea BlockchainYahoo
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
SignalToNoise(length) =>
StN = 0.0
for i = 1 to length-1
StN := StN + (1/close[i])/length
StN := -10*log(StN)
strategy(title="Backtest Signal To Noise ", shorttitle="StoN", overlay=false)
length = input(title="Days", type=input.integer, defval=21, minval=2)
Smooth = input(title="Smooth", type=input.integer, defval=7, minval=2)
reverse = input(false, title="Trade reverse")
StN = SignalToNoise(length)
SMAStN = sma(StN, Smooth)
pos = iff(SMAStN[1] > StN[1] , -1,
iff(SMAStN[1] < StN[1], 1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1 , 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )
plot(StN, title='StN' )
plot(SMAStN, title='Smooth', color=#00ff00)
Detail
https://www.fmz.com/strategy/437403
Last Modified
2024-01-02 12:24:35