Skip to content

Latest commit

 

History

History
187 lines (148 loc) · 6.9 KB

基于信噪比和均线的量化交易策略Signal-to-Noise-Moving-Average-Trading-Strategy-Based-on-Quantitative-Trading.md

File metadata and controls

187 lines (148 loc) · 6.9 KB

Name

基于信噪比和均线的量化交易策略Signal-to-Noise-Moving-Average-Trading-Strategy-Based-on-Quantitative-Trading

Author

ChaoZhang

Strategy Description

IMG [trans]

一、策略名称

信噪比均线交易策略(Signal-to-Noise Moving Average Trading Strategy)

二、策略概述

该策略通过计算一定周期内的信噪比,再结合均线交易信号,实现量化交易。其基本思路是:

  1. 计算一定周期(可设定)的信噪比
  2. 对信噪比应用均线平滑
  3. 比较当前信噪比与均线值,产生交易信号
  4. 根据交易信号做多头或空头

三、策略原理

  1. 信噪比(Signal to Noise Ratio)的计算公式为:StN = -10*log(Σ(1/close)/n) 其中n为周期长度
  2. 对信噪比应用简单移动平均(SMA)得到平滑信噪比
  3. 比较当前信噪比StN与平滑信噪比SMAStN: (1) 如果SMAStN > StN,做空 (2) 如果SMAStN < StN,做多 (3) 否则清仓

四、策略优势分析

该策略主要有以下优势:

  1. 信噪比能判断市场波动和风险,SMA有去噪功能
  2. 结合信噪比判断市场风险与SMA产生交易信号,运用不同指标优势
  3. 可设定参数调整策略,适应不同市场情况
  4. 可Stdout信号指示做多做空,直观判断市场特征

五、策略风险分析

该策略也存在一些风险:

  1. 信噪比与均线交叉判断存在错位风险
  2. 周期设定不当可能导致虚假信号
  3. 做空机会相对少,可通过参数调整优化
  4. 突发事件导致剧烈波动,可能触发止损

风险解决:

  1. 调整均线参数,避免平滑过度
  2. 优化周期参数,测试不同市场适应性
  3. 调整做空条件,提供更多做空机会
  4. 设置止损以控制最大损失

六、策略优化方向

该策略可以从以下方面进行优化:

  1. 测试更多类型均线的搭配使用
  2. 增加止损机制控制风险
  3. 增加仓位管理,根据波动调整仓位
  4. 结合更多因子判断,提高策略稳定性
  5. 使用机器学习方法自动优化参数

七、总结

本策略通过信噪比判断市场波动风险,并利用均线产生交易信号,实现量化交易。相比单一技术指标,本策略整合信噪比与SMA各自的优势,在控制风险的同时提高稳定性。通过参数优化与机器学习等方式,本策略有很大的改进空间,是一种可靠、有效的量化交易策略。

||

I. Strategy Name

Signal-to-Noise Moving Average Trading Strategy

II. Strategy Overview

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:

  1. Calculate the signal-to-noise ratio over a certain period (adjustable)
  2. Apply moving average to smooth the signal-to-noise ratio
  3. Compare current signal-to-noise ratio with moving average value to generate trading signals
  4. Long or short based on trading signals

III. Strategy Principle

  1. The formula for calculating signal-to-noise ratio (StN) is: StN = -10*log(Σ(1/close)/n), where n is the length of the period
  2. Apply Simple Moving Average (SMA) to the signal-to-noise ratio to obtain smoothed StN
  3. Compare current StN with smoothed SMAStN: (1) If SMAStN > StN, go short (2) If SMAStN < StN, go long (3) Otherwise, close position

IV. Advantage Analysis

The main advantages of this strategy are:

  1. StN can judge market fluctuation and risk, SMA has noise reduction capability
  2. Combining StN to judge market risk and SMA to generate trading signals makes use of the advantages of different indicators
  3. Adjustable parameters to adapt to different market conditions
  4. Stdout signals directly indicate long or short, intuitive judgment of market characteristics

V. Risk Analysis

There are also some risks with this strategy:

  1. Crossing judgment between StN and MA exists deviation risk
  2. Improper period settings may cause false signals
  3. Relative fewer short opportunities, optimizable via parameter adjustment
  4. Extreme fluctuations caused by black swan events may trigger stop loss

Solutions:

  1. Adjust MA parameters to avoid over-smoothing
  2. Optimize period parameters and test adaptability in different markets
  3. Adjust short conditions to provide more short opportunities
  4. Set stop loss to control maximum losses

VI. Optimization Direction

The strategy can be optimized in the following ways:

  1. Test combination of more types of moving averages
  2. Add stop loss mechanism to control risks
  3. Add position management, adjust positions based on fluctuations
  4. Incorporate more factors to improve stability
  5. Use machine learning methods to automatically optimize parameters

VII. Summary

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