Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Telegram !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Indicateurs

YURAZ_MCCH - indicateur pour MetaTrader 5

Yuriy Zaytsev
Yuriy Zaytsev
  • Свободный художник à  Сам на себя
  • Russie
  • 23914
5 (20)
My EA took 6th place among the world's best EA developer in the world in 2007
https://championship.mql5.com/2011/ru/users/index
| French English Русский 中文 Español Deutsch 日本語 Português 한국어 Italiano Türkçe
Vues:
372
Note:
(33)
Publié:
Mise à jour:
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

Cet indicateur calcule le pourcentage de hausse ou de baisse par rapport au cours de clôture ; il est écrit en POO et s'intègre facilement à n'importe quel expert ou autre indicateur.

  • L'indicateur calcule le CH%, c'est-à-dire le pourcentage de variation par rapport au cours de clôture de la veille.
  • Il crée des objets sur le graphique. L'indicateur est écrit dans le style de la programmation orientée objet (POO).
  • Il s'intègre très facilement à n'importe quel expert ou autre indicateur : il suffit de définir la classe et d'en appeler la méthode.

Vous pouvez évaluer la taille du code à intégrer dans un autre indicateur ou un autre expert.

Cela représente 2 lignes

CChmcYZ chmc;

chmc.RCHsay("EURUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16); // Calculons le pourcentage de CH% pour cette journée

La programmation orientée objet offre de nombreuses possibilités : vous écrivez les classes nécessaires, puis vous concevez...


//+------------------------------------------------------------------+
//|                                                   yuraz_mcch.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// classe de calcul CH% 
//
struct SymbolStruct
  {
   bool              work;
   string            sSymbol;
   int               y;
   int               x;
   double            CH;
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CChmcYZ
  {
public:
   SymbolStruct      sSymb;
   color             lColorSym;
   color             lColorChPlus;
   color             lColorChMinus;
   color             lColorCH;
   
   int               indicatorWindow; // nous travaillons dans la fenêtre principale
   void CChmcYZ()    { 
   indicatorWindow=0;
   lColorSym=DarkBlue; //  Turquoise foncé
   lColorCH=DarkGreen; // Blanc ; 
   lColorChPlus  = Green; // LimeGreen ;
   lColorChMinus = FireBrick ; // Rouge ;
    } // constructeur
   void              RCH(string sSym,datetime db,datetime de);   // Calcul complet d'une seule paire sans affichage
   void              RCHsay(string sSym,datetime db,datetime de,int X,int Y); // Calcul complet d'une paire et affichage de celle-ci
private:
   color lColor;
   double            dClose[7000];                    // tableau destiné à stocker les prix maximaux
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CChmcYZ::RCH(string sSymbol,datetime DATEBEG,datetime DATEEND)
  {
   sSymb.CH = 0;
   int CountBar;
   DATEBEG = StringToTime( TimeToString(DATEBEG,TIME_DATE));
   DATEEND = StringToTime( TimeToString(DATEEND,TIME_DATE));
   CountBar= CopyClose(sSymbol,PERIOD_D1,DATEEND,2,dClose);
   if(CountBar>=0)
     {
      if(NormalizeDouble(dClose[1],5)!=0.0 && NormalizeDouble(dClose[0],5)!=0.0)
        {
         sSymb.CH=(dClose[1]*100)/dClose[0]-100;
        }
     }
  }
//+------------------------------------------------------------------+
//| Calcul avec affichage du résultat
//+------------------------------------------------------------------+
void CChmcYZ::RCHsay(string sSym,datetime db,datetime de,int XD,int YD) // Calcul complet pour une seule paire
  {
   RCH(sSym,db,de);
   if(ObjectFind(indicatorWindow,"oYZ"+sSym)==-1)
     {
      ObjectCreate(indicatorWindow,"oYZ"+sSym,OBJ_LABEL,indicatorWindow,0,0);
      ObjectSetInteger(indicatorWindow,"oYZ"+sSym,OBJPROP_XDISTANCE,XD);
      ObjectSetInteger(indicatorWindow,"oYZ"+sSym,OBJPROP_YDISTANCE,YD);
      ObjectSetInteger(indicatorWindow,"oYZ"+sSym,OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSetString(indicatorWindow,"oYZ"+sSym,OBJPROP_TEXT,sSym);
      ObjectSetString(indicatorWindow,"oYZ"+sSym,OBJPROP_FONT,"Arial");
      ObjectSetInteger(indicatorWindow,"oYZ"+sSym,OBJPROP_FONTSIZE,7);
      ObjectSetInteger(indicatorWindow,"oYZ"+sSym,OBJPROP_COLOR,lColorSym);
      ObjectSetInteger(indicatorWindow,"oYZ"+sSym,OBJPROP_SELECTABLE,true);
     }
   if(ObjectFind(indicatorWindow,"oYZ_"+sSym)==-1)
     {
      ObjectCreate(indicatorWindow,"oYZ_"+sSym,OBJ_LABEL,indicatorWindow,0,0);
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_XDISTANCE,XD+45);
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_YDISTANCE,YD);
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSetString(indicatorWindow,"oYZ_"+sSym,OBJPROP_TEXT,sSym);
      ObjectSetString(indicatorWindow,"oYZ_"+sSym,OBJPROP_FONT,"Arial");
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_FONTSIZE,7);
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_COLOR,lColorCH);
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_SELECTABLE,true);
     }
   YD=YD+11;

   lColor=lColorCH;
   if(sSymb.CH>0)
     {
      lColor=lColorChPlus;
      ObjectSetString(indicatorWindow,"oYZ_"+sSym,OBJPROP_TEXT," "+DoubleToString(sSymb.CH,5));
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_XDISTANCE,XD+45);
     }
   if(sSymb.CH<0)
     {
      lColor=lColorChMinus;
      ObjectSetString(indicatorWindow,"oYZ_"+sSym,OBJPROP_TEXT,DoubleToString(sSymb.CH,5));
      ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_XDISTANCE,XD+46);
     }
   ObjectSetInteger(indicatorWindow,"oYZ_"+sSym,OBJPROP_COLOR,lColor);
  }
//
// fin de la classe
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Code utilisant la classe
// 

CChmcYZ chmc;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Mappage des tampons d'indicateurs
   chmc.RCHsay("EURUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16); // Calculons le pourcentage de CH% pour cette journée
   chmc.RCHsay("AUDUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16+12   );
   chmc.RCHsay("GBPUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16+12*2 );
   chmc.RCHsay("USDCHF",TimeCurrent()-86400*5,TimeCurrent(),5,16+12*3 );
   chmc.RCHsay("USDCAD",TimeCurrent()-86400*5,TimeCurrent(),5,16+12*4 );
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   chmc.RCHsay("EURUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16); // Calculons le pourcentage de CH% pour cette journée
   chmc.RCHsay("AUDUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16+12   );
   chmc.RCHsay("GBPUSD",TimeCurrent()-86400*5,TimeCurrent(),5,16+12*2 );
   chmc.RCHsay("USDCHF",TimeCurrent()-86400*5,TimeCurrent(),5,16+12*3 );
   chmc.RCHsay("USDCAD",TimeCurrent()-86400*5,TimeCurrent(),5,16+12*4 );
   return(rates_total);
  }

 void OnDeinit()
  {
   int i=ObjectsTotal(0); // supprimons nos objets
   while( i > 0  )
     {
      if(StringSubstr(ObjectName(0,i ),0,3)=="oYZ")
        {
         ObjectDelete(0,ObjectName(0,i ));
        }
        i--;
      }
  }

Traduit du russe par MetaQuotes Ltd.
Code original : https://www.mql5.com/ru/code/11347

MACD Signals MACD Signals

Version des indicateurs pour la nouvelle plateforme.

CTsLogger est un système d'enregistrement simple et flexible. CTsLogger est un système d'enregistrement simple et flexible.

Logger avec la possibilité d'enregistrer des modules individuels ou des sections de code

YURAZ_RSAXEL : ce script trace les niveaux de Rudolf Axel YURAZ_RSAXEL : ce script trace les niveaux de Rudolf Axel

Le script trace les niveaux de Rudolf Axel

Divergence RSI Divergence RSI

Cet indicateur prend les divergences RSI et les trace dans des tampons pour automatiser les EA.