Stratégie de suivi de la tendance à double renversement

Auteur:ChaoZhang est là., Date: 2023-12-13 18h01:53 Je vous en prie.
Les étiquettes:

img

Résumé

Il s'agit d'une stratégie de suivi de tendance qui combine deux signaux d'inversion.

Principe de stratégie

La stratégie est composée de deux sous-stratégies:

  1. 123 Stratégie d'inversion

    Utilisez la ligne K de 14 jours pour juger des signaux d'inversion.

    • Signal haussier: le prix de clôture a chuté au cours des deux jours précédents. Le prix de clôture actuel de la ligne K est supérieur au prix de clôture de la journée précédente.
    • Signal baissier: le prix de clôture a augmenté au cours des deux jours précédents. Le prix de clôture actuel de la ligne K est inférieur au prix de clôture de la journée précédente.
  2. Stratégie de l'indice de performance

    Calculer le pourcentage d'augmentation/de diminution au cours des 14 derniers jours à titre d'indicateur.

    • Indice de performance > (0), générer un signal haussier - Indice de performance <(0), génère un signal baissier

Le signal final est une combinaison des deux signaux, c'est-à-dire que des signaux haussiers/baissiers dans la même direction sont nécessaires pour générer des opérations d'achat/de vente réelles.

Cela peut filtrer un peu de bruit et rendre les signaux plus fiables.

Les avantages de la stratégie

Ce double système d'inversion présente les avantages suivants:

  1. Des signaux plus fiables grâce à la combinaison de deux facteurs
  2. Peut filtrer efficacement le bruit du marché et éviter les faux signaux
  3. 123 modèle est classique et pratique, facile à juger et à reproduire
  4. L'indice de performance peut juger de l'orientation de la tendance future
  5. Combinaison de paramètres flexible, peut être optimisée davantage

Risques liés à la stratégie

La stratégie comporte également certains risques:

  1. Peut manquer des revers soudains, ne pas pouvoir saisir pleinement les tendances
  2. Les combinaisons de signaux doubles entraînent moins de signaux, ce qui peut affecter la rentabilité.
  3. Requiert un jugement cohérent, facilement affecté par les fluctuations individuelles des stocks
  4. Les problèmes de réglage des paramètres peuvent entraîner des écarts de signal

Les aspects suivants peuvent être pris en considération pour l'optimisation:

  1. Ajustez les paramètres tels que la longueur de la ligne K, le cycle stochastique, etc.
  2. Optimiser la logique pour le jugement du double signal
  3. Incorporer plus de facteurs comme le volume, etc.
  4. Ajouter un mécanisme de stop loss

Résumé

La stratégie intègre des jugements d'inversion doubles pour détecter efficacement les points d'inflexion des prix. Bien que la probabilité d'apparition du signal diminue, la fiabilité est plus élevée, adaptée à la capture des tendances à moyen et long terme.


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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 15/04/2021
// 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 Performance indicator or a more familiar term, KPI (key performance indicator), 
// is an industry term that measures the performance. Generally used by organizations, 
// they determine whether the company is successful or not, and the degree of success. 
// It is used on a business’ different levels, to quantify the progress or regress of a 
// department, of an employee or even of a certain program or activity. For a manager 
// it’s extremely important to determine which KPIs are relevant for his activity, and 
// what is important almost always depends on which department he wants to measure the 
// performance for.  So the indicators set for the financial team will be different than 
// the ones for the marketing department and so on.
//
// Similar to the KPIs companies use to measure their performance on a monthly, quarterly 
// and yearly basis, the stock market makes use of a performance indicator as well, although 
// on the market, the performance index is calculated on a daily basis. The stock market 
// performance indicates the direction of the stock market as a whole, or of a specific stock 
// and gives traders an overall impression over the future security prices, helping them decide 
// the best move. A change in the indicator gives information about future trends a stock could 
// adopt, information about a sector or even on the whole economy. The financial sector is the 
// most relevant department of the economy and the indicators provide information on its overall 
// health, so when a stock price moves upwards, the indicators are a signal of good news. On the 
// other hand, if the price of a particular stock decreases, that is because bad news about its 
// performance are out and they generate negative signals to the market, causing the price to go 
// downwards. One could state that the movement of the security prices and consequently, the movement 
// of the indicators are an overall evaluation of a country’s economic trend.
//
// 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


PI(Period) =>
    pos = 0.0
    xKPI = (close - close[Period]) * 100 / close[Period]
    pos := iff(xKPI > 0, 1,
              iff(xKPI < 0, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Perfomance index", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Perfomance index ----")
Period = input(14, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPI = PI(Period)
pos = iff(posReversal123 == 1 and posPI == 1 , 1,
	   iff(posReversal123 == -1 and posPI == -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 )

Plus de