Estratégia de reversão de duplo clique

Autora:ChaoZhang, Data: 2023-11-22 10:03:04
Tags:

img

Resumo

Esta estratégia utiliza primeiro o padrão 123 para determinar o sinal de reversão e, em seguida, combina o Oscilador de Volume Klinger como um filtro para implementar a estratégia de lucro quantitativo de duplo clique para capturar eficientemente oportunidades de reversão.

Princípio

A estratégia consiste em duas partes:

  1. Modelo para determinar sinais de reversão: quando o preço de fechamento cai continuamente durante 2 dias consecutivos e o terceiro dia fecha positivo, e o indicador de ações está em um nível baixo por muito tempo; quando o preço de fechamento sobe continuamente durante 2 dias consecutivos e o terceiro dia fecha negativo, e o indicador de ações está em um nível alto por curto.

  2. Seção do oscilador de volume Klinger: O oscilador de volume Klinger combina a faixa de flutuação de preços e as mudanças no volume de negociação para determinar as entradas e saídas de capital.

Por fim, a estratégia combina os sinais das duas partes acima e os duplos cliques para determinar a entrada final.

Análise das vantagens

A maior vantagem desta estratégia é que combina padrões de reversão e indicadores de volume para capturar eficientemente oportunidades de reversão.

Análise de riscos

Os principais riscos desta estratégia estão no problema do julgamento do padrão de reversão e configuração de parâmetros. Devido ao atraso nos sinais de reversão, ele precisa garantir que os parâmetros sejam definidos de forma razoável para evitar perder o melhor momento de reversão. Além disso, os próprios padrões de reversão podem falhar.

Para reduzir os riscos, você pode otimizar os parâmetros para tornar os sinais de reversão mais responsivos e oportunos. Outros filtros também podem ser adicionados para garantir um número e amplitude suficientes de reversões para evitar declínios maiores.

Direcção de otimização

O principal espaço de otimização para esta estratégia está no ajuste de parâmetros e adição de outros julgamentos auxiliares. Especificamente, é possível encurtar adequadamente os parâmetros do indicador de estoque para otimizar a sensibilidade da discriminação de padrões. Também é viável combiná-lo com os principais indicadores e padrões atuais, como adicionar cruzes douradas e cruzes mortais do MACD, ou baixas múltiplas duplas e outros julgamentos.

Além disso, considere ajustar dinamicamente as condições de stop loss e take profit para tornar a estratégia mais adaptável às mudanças do mercado.

Resumo

Esta estratégia integra a aplicação de teorias clássicas de reversão e indicadores técnicos de volume para capturar de forma eficiente oportunidades de reversão.


/*backtest
start: 2023-10-22 00:00:00
end: 2023-11-21 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 23/12/2020
// This is combo strategies for get a cumulative signal. 
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The Klinger Oscillator (KO) was developed by Stephen J. Klinger. Learning 
// from prior research on volume by such well-known technicians as Joseph Granville, 
// Larry Williams, and Marc Chaikin, Mr. Klinger set out to develop a volume-based 
// indicator to help in both short- and long-term analysis.
// The KO was developed with two seemingly opposite goals in mind: to be sensitive 
// enough to signal short-term tops and bottoms, yet accurate enough to reflect the 
// long-term flow of money into and out of a security.
// The KO is based on the following tenets:
// Price range (i.e. High - Low) is a measure of movement and volume is the force behind 
// the movement. The sum of High + Low + Close defines a trend. Accumulation occurs when 
// today's sum is greater than the previous day's. Conversely, distribution occurs when 
// today's sum is less than the previous day's. When the sums are equal, the existing trend 
// is maintained.
// Volume produces continuous intra-day changes in price reflecting buying and selling pressure. 
// The KO quantifies the difference between the number of shares being accumulated and distributed 
// each day as "volume force". A strong, rising volume force should accompany an uptrend and then 
// gradually contract over time during the latter stages of the uptrend and the early stages of 
// the following downtrend. This should be followed by a rising volume force reflecting some 
// accumulation before a bottom develops.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos

KVO(TrigLen,FastX,SlowX) =>
    pos = 0.0
    xTrend = iff(hlc3 > hlc3[1], volume * 100, -volume * 100)
    xFast = ema(xTrend, FastX)
    xSlow = ema(xTrend, SlowX)
    xKVO = xFast - xSlow
    xTrigger = ema(xKVO, TrigLen)
    pos := iff(xKVO > xTrigger, 1,
    	     iff(xKVO < xTrigger, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Klinger Volume Oscillator", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
TrigLen = input(13, minval=1)
FastX = input(34, minval=1)
SlowX = input(55, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posKVO = KVO(TrigLen,FastX,SlowX)
pos = iff(posReversal123 == 1 and posKVO == 1 , 1,
	   iff(posReversal123 == -1 and posKVO == -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 )

Mais.