MetaTrader5
Bollinger Bands Personnalisées : Un Indicateur Innovant pour MetaTrader 5
Salut les traders ! Aujourd'hui, je vais vous parler d'un indicateur que j'ai développé pour améliorer votre expérience avec les Bollinger Bands sur MetaTrader 5. Contrairement à l'indicateur standard qui ne propose que la méthode de moyenne mobile simple, le mien vous offre plusieurs options pour personnaliser votre analyse : Exponentielle, Lissee, et Pondérée Linéaire.
Pour installer cet indicateur, il vous suffit de le placer dans le répertoire suivant sur votre ordinateur Windows :
C:\Users\votre_nom\AppData\Roaming\MetaQuotes\Terminal\Indicators\Examples
Voici quelques fonctionnalités ajoutées :
Par défaut, les réglages sont à zéro :
Voici un exemple d'exécution en choisissant la méthode de moyenne pondérée linéaire :
CODE :
//+------------------------------------------------------------------+
//| BBPersonnalisee.mq5 |
//| Lucas Vidal |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Lucas Vidal"
#property link "https://www.mql5.com/en/users/lucasmoura00"
#property description "Bollinger Bands Personnalisées"
#include <MovingAverages.mqh>
//---
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots 3
#property indicator_type1 DRAW_LINE
#property indicator_color1 LightSeaGreen
#property indicator_type2 DRAW_LINE
#property indicator_color2 LightSeaGreen
#property indicator_type3 DRAW_LINE
#property indicator_color3 LightSeaGreen
#property indicator_label1 "Bands middle"
#property indicator_label2 "Bands upper"
#property indicator_label3 "Bands lower"
//--- paramètres d'entrée
enum MovingAverageMethod {
Simple, // 0
Exponential, // 1
Smoothed, // 2
LinearWeighted // 3
};
input MovingAverageMethod InpMaMethod = Simple; // Méthode de la Moyenne Mobile
input int InpBandsPeriod=20; // Période
input int InpBandsShift=0; // Décalage
input double InpBandsDeviations=2.0; // Écart-type
//--- variables globales
int ExtBandsPeriod, ExtBandsShift;
double ExtBandsDeviations;
int ExtPlotBegin=0;
//--- buffer de l'indicateur
double ExtMLBuffer[];
double ExtTLBuffer[];
double ExtBLBuffer[];
double ExtStdDevBuffer[];
//+------------------------------------------------------------------+
//| Fonction d'initialisation de l'indicateur |
//+------------------------------------------------------------------+
void OnInit() {
//--- vérification des valeurs d'entrée
if(InpBandsPeriod<2) {
ExtBandsPeriod=20;
PrintFormat("Valeur incorrecte pour la variable d'entrée InpBandsPeriod=%d. L'indicateur utilisera la valeur=%d pour les calculs.", InpBandsPeriod, ExtBandsPeriod);
} else
ExtBandsPeriod=InpBandsPeriod;
if(InpBandsShift<0) {
ExtBandsShift=0;
PrintFormat("Valeur incorrecte pour la variable d'entrée InpBandsShift=%d. L'indicateur utilisera la valeur=%d pour les calculs.", InpBandsShift, ExtBandsShift);
} else
ExtBandsShift=InpBandsShift;
if(InpBandsDeviations==0.0) {
ExtBandsDeviations=2.0;
PrintFormat("Valeur incorrecte pour la variable d'entrée InpBandsDeviations=%f. L'indicateur utilisera la valeur=%f pour les calculs.", InpBandsDeviations, ExtBandsDeviations);
} else
ExtBandsDeviations=InpBandsDeviations;
//--- définir les buffers
SetIndexBuffer(0, ExtMLBuffer);
SetIndexBuffer(1, ExtTLBuffer);
SetIndexBuffer(2, ExtBLBuffer);
SetIndexBuffer(3, ExtStdDevBuffer, INDICATOR_CALCULATIONS);
//--- définir les étiquettes d'index
PlotIndexSetString(0, PLOT_LABEL, "Bands("+string(ExtBandsPeriod)+") Middle");
PlotIndexSetString(1, PLOT_LABEL, "Bands("+string(ExtBandsPeriod)+") Upper");
PlotIndexSetString(2, PLOT_LABEL, "Bands("+string(ExtBandsPeriod)+") Lower");
//--- nom de l'indicateur
IndicatorSetString(INDICATOR_SHORTNAME, "Bollinger Bands");
//--- paramètres de début de dessin des index
ExtPlotBegin=ExtBandsPeriod-1;
PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, ExtBandsPeriod);
PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, ExtBandsPeriod);
PlotIndexSetInteger(2, PLOT_DRAW_BEGIN, ExtBandsPeriod);
//--- paramètres de décalage des index
PlotIndexSetInteger(0, PLOT_SHIFT, ExtBandsShift);
PlotIndexSetInteger(1, PLOT_SHIFT, ExtBandsShift);
PlotIndexSetInteger(2, PLOT_SHIFT, ExtBandsShift);
//--- nombre de chiffres de la valeur de l'indicateur
IndicatorSetInteger(INDICATOR_DIGITS, _Digits+1);
}
//+------------------------------------------------------------------+
J'espère que cet indicateur vous sera utile et que vous pourrez l'intégrer dans vos stratégies de trading ! N'hésitez pas à partager vos retours d'expérience et vos astuces en commentaires. Bonne chance dans vos trades !
2024.04.28