
La stratégie de dynamique de la régression moyenne est une stratégie de négociation de tendance qui suit la moyenne des prix à court terme. Elle combine l’indicateur de la régression moyenne et l’indicateur de la dynamique pour déterminer la tendance à moyen terme du marché.
La stratégie commence par calculer la ligne de régression moyenne et le décalage standard. Puis, en combinant les paramètres de seuil supérieur et de seuil inférieur, elle calcule si le prix est au-delà d’une marge de décalage standard. Si elle est dépassée, elle génère un signal de transaction.
Pour les signaux à plusieurs têtes, le prix doit être inférieur à la ligne de retour de la valeur moyenne d’un écart standard, le prix de clôture doit être inférieur à la moyenne SMA du cycle LENGTH et supérieur à la moyenne SMA de la tendance, pour que ces trois conditions soient remplies. La condition de placement est la moyenne SMA du cycle LENGTH sur le prix.
Pour les signaux de tête vide, le prix doit être supérieur à la ligne de retour de la valeur moyenne d’un écart standard, le prix de clôture doit être supérieur à la moyenne SMA du cycle LENGTH et inférieur à la moyenne SMA de la tendance, pour que les trois conditions soient remplies. La condition de placement est la moyenne SMA du cycle LENGTH.
Cette stratégie est combinée avec le Percent Profit Target et le Percent Stop Loss pour réaliser une gestion de stop loss.
La méthode d’exit peut choisir entre une rupture de la moyenne mobile ou une rupture de la régression linéaire.
Il est possible de juger et de suivre les tendances du marché à moyen terme grâce à une combinaison de négociation bilatérale multi-channel, de filtrage de tendance et de stop-loss.
L’indicateur de régression de la valeur moyenne permet de déterminer efficacement si le prix est éloigné du centre de la valeur
Les SMA peuvent filtrer le bruit des marchés à court terme
Les échanges bilatéraux multicouches permettent de saisir toutes les opportunités de tendances
Les mécanismes de stop-loss permettent de contrôler efficacement les risques
Des options d’exit qui permettent de s’adapter au marché
Une stratégie de trading de tendance complète pour mieux saisir les tendances à moyen terme
L’indicateur de régression de la moyenne est sensible aux paramètres, un mauvais réglage des seuils peut entraîner de faux signaux
Les dommages trop fréquents peuvent survenir lors de tremblements de terre importants.
La fréquence des transactions peut être trop élevée en période de choc, ce qui augmente les frais de transaction et le risque de glissement
Le contrôle des points de glissement peut ne pas être idéal lorsque la variété de transaction est peu liquide.
Les transactions bilatérales multilatérales sont plus risquées et nécessitent une gestion prudente des fonds
Ces risques peuvent être maîtrisés par des méthodes telles que l’optimisation des paramètres, l’ajustement de la méthode d’arrêt des pertes et la gestion des fonds.
Optimisation des paramètres de la régression de la moyenne et de l’indicateur de dynamique pour les rendre plus adaptés aux caractéristiques des différentes variétés
Augmenter les indicateurs de jugement des tendances et améliorer la capacité d’identification des tendances
Optimiser les stratégies de stop loss pour mieux s’adapter aux fortes fluctuations du marché
Ajout d’un module de gestion des positions pour ajuster la taille des positions en fonction des conditions du marché
Ajout d’autres modules de contrôle du vent, tels que le contrôle de la retraite maximale, le contrôle de la courbe de valeur nette, etc.
Considérer des méthodes d’apprentissage automatique pour optimiser automatiquement les paramètres de la stratégie
Dans l’ensemble, la stratégie de dynamique de la régression des valeurs moyennes capture les tendances de la régression des valeurs à moyen terme grâce à une conception de l’indicateur simple et efficace. La stratégie a une forte adaptabilité et une adaptabilité universelle, mais il existe également un certain risque.
/*backtest
start: 2023-10-15 00:00:00
end: 2023-11-14 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GlobalMarketSignals
//@version=4
strategy("GMS: Mean Reversion Strategy", overlay=true)
LongShort = input(title="Long Only or Short Only or Both?", type=input.string, defval="Both", options=["Both", "Long Only", "Short Only"])
Lookback = input(title="Length", type=input.integer, defval=10, minval=0)
LThr1 = input(title="Upper threshold", type=input.float, defval=1, minval=0)
LThr = input(title="Lower threshold", type=input.float, defval=-1, maxval=0)
src = input(title="Source", type=input.source, defval=close)
LongShort2 = input(title="Linear Regression Exit or Moving Average Exit?", type=input.string, defval="MA", options=["LR", "MA"])
SMAlenL = input(title="MA/LR Exit Length", type = input.integer ,defval=10)
SMALen2 = input(title="Trend SMA Length", type = input.integer ,defval=200)
AboveBelow = input(title="Above or Below Trend SMA?", type=input.string, defval="Above", options=["Above", "Below", "Don't Include"])
PTbutton = input(title="Profit Target On/Off", type=input.bool, defval=true)
ProfitTarget = input(title="Profit Target %", type=input.float, defval=1, step=0.1, minval=0)
SLbutton = input(title="Stop Loss On/Off", type=input.bool, defval=true)
StopLoss = input(title="Stop Loss %", type=input.float, defval=-1, step=0.1, maxval=0)
x = (src-linreg(src,Lookback,0))/(stdev(src,Lookback))
plot(linreg(src,Lookback,0))
//PROFIT TARGET & STOPLOSS
if PTbutton == true and SLbutton == true
strategy.exit("EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick), loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
if PTbutton == true and SLbutton == false
strategy.exit("PT EXIT", profit=((close*(ProfitTarget*0.01))/syminfo.mintick))
else
if PTbutton == false and SLbutton == true
strategy.exit("SL EXIT", loss=((close*(StopLoss*-0.01))/syminfo.mintick))
else
strategy.cancel("PT EXIT")
////////////////////////
//MOVING AVERAGE EXIT//
//////////////////////
if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
strategy.close("LONG", when = close>sma(close,SMAlenL))
///////
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) )
strategy.close("SHORT", when = close<sma(close,SMAlenL))
//////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("LONG", true, when = x<LThr and close<sma(close,SMAlenL) )
strategy.close("LONG", when = close>sma(close,SMAlenL))
///////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<sma(close,SMAlenL))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="MA"
strategy.entry("SHORT", false, when = x>LThr1 and close>sma(close,SMAlenL) )
strategy.close("SHORT", when = close<sma(close,SMAlenL))
/////////////////
//LIN REG EXIT//
///////////////
if LongShort=="Long Only" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Long Only" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Long Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
///////
if LongShort=="Short Only" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Short Only" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Short Only" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) )
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
//////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("LONG", true, when = x<LThr and close<linreg(close,SMAlenL,0) )
strategy.close("LONG", when = close>linreg(close,SMAlenL,0))
///////
if LongShort=="Both" and AboveBelow=="Above" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close>sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Below" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) and close<sma(close,SMALen2))
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))
if LongShort=="Both" and AboveBelow=="Don't Include" and LongShort2 =="LR"
strategy.entry("SHORT", false, when = x>LThr1 and close>linreg(close,SMAlenL,0) )
strategy.close("SHORT", when = close<linreg(close,SMAlenL,0))