Qu'est Que Sont "le Nombre De Points" Dans Les Tableaux De Corrélation ? - Forex Forum

Welcome Guest ( Log In | Register )

 
> Qu'est Que Sont "le Nombre De Points" Dans Les Tableaux De Corrélation ?
Arnaud Jeulin
post Jun 24 2008, 14:27
Post


Qu'est que sont "le nombre de points" dans les tableaux de corrélation ?

D'après Wikipédia :
En probabilités et en statistique, étudier la corrélation entre deux ou plusieurs variables aléatoires ou statistiques, c'est étudier l'intensité de la liaison qui peut exister entre ces variables. La liaison recherchée est une relation affine. Dans le cas de deux variables, il s'agit de la régression linéaire.

Une mesure de cette corrélation est obtenue par le calcul du coefficient de corrélation linéaire. Ce coefficient est égal au rapport de leur covariance et du produit non nul de leurs écarts types (en anglais standard deviations) . Le coefficient de corrélation est compris entre -1 et 1.


Dans nos tableaux de corrélation les deux variables aléatoires sont deux paires de devises, et le nombre de points indique le nombre de data sur lesquelles sont calculées la corrélation.

Exemple : Je veux calculer la corrélation horaire entre EURUSD et GBPUSD des 24 dernières heures.
Je sélectionne EURUSD et GBPUSD et j'indique un nombre de points à 24.

Voici un graphe qui devrait être plus clair :
Attached Image
betino83
post Jun 24 2008, 15:56
Post


Et dans la continuité de ce post, voici le code pour MT4, selectionnez 2 paires et le nombre de points et le tour est joué.







Code
//+------------------------------------------------------------------+
//|                                               Correlation_v1.mq4 |
//|                           Copyright © 2006, TrendLaboratory Ltd. |
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |
//|                                       E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DeepSkyBlue
#property indicator_maximum 1.05
#property indicator_minimum -1.05

//---- input parameters
extern string    Symbol1="GBPUSD";
extern string    Symbol2="EURUSD";
extern int       cPeriod=20;

//---- buffers
double Correlation[];
double DiffBuffer1[];
double DiffBuffer2[];
double PowDiff1[];
double PowDiff2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(5);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Correlation);
   SetIndexBuffer(1,DiffBuffer1);
   SetIndexBuffer(2,DiffBuffer2);
   SetIndexBuffer(3,PowDiff1);
   SetIndexBuffer(4,PowDiff2);
//----
   string short_name="Correlation("+Symbol1+","+Symbol2+","+cPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
  
   SetIndexDrawBegin(0,2*cPeriod);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int shift,limit,counted_bars=IndicatorCounted();
  
   if ( counted_bars < 0 ) return(-1);
   if ( counted_bars ==0 ) limit=Bars-cPeriod-1;
   if ( counted_bars < 1 )
   for(int i=1;i<2*cPeriod;i++) Correlation[Bars-i]=0;    
      
   if(counted_bars>0) limit=Bars-counted_bars;
   limit--;
  
   for( shift=limit; shift>=0; shift--)
   {
//----
   DiffBuffer1[shift]=iClose(Symbol1,0,shift)-iMA(Symbol1,0,cPeriod,0,MODE_SMA,PRICE_CLOSE,shift);
   DiffBuffer2[shift]=iClose(Symbol2,0,shift)-iMA(Symbol2,0,cPeriod,0,MODE_SMA,PRICE_CLOSE,shift);
   PowDiff1[shift]=MathPow(DiffBuffer1[shift],2);
   PowDiff2[shift]=MathPow(DiffBuffer2[shift],2);
  
      double u=0,l=0,s=0;
      
      for( i = cPeriod-1;i >= 0;i--)
      {
      u += DiffBuffer1[shift+i]*DiffBuffer2[shift+i];
      l += PowDiff1[shift+i];
      s += PowDiff2[shift+i];
      }
      
   if(l*s >0) Correlation[shift]=u/MathSqrt(l*s);
  
  }
  
//----
   return(0);
  }
//+------------------------------------------------------------------+






This post has been edited by betino83: Jun 24 2008, 19:48
Arnaud Jeulin
post Jun 24 2008, 17:46
Post


En rafraichissant ça devrait être correct maintenant

Reply to this topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   1 Arnaud Jeulin 4,278 13th September 2005 - 20:58
Last post by: Arnaud
No New Posts   2 Arnaud Jeulin 6,255 18th July 2008 - 15:04
Last post by: Damien
No New Posts   0 FXPrice 2,723 19th September 2005 - 22:12
Last post by: FXPrice
No New Posts   0 FXPrice 2,358 18th September 2005 - 23:44
Last post by: FXPrice
No New Posts   0 FXPrice 2,073 22nd September 2005 - 22:15
Last post by: FXPrice


Lo-Fi Version: Qu'est Que Sont "le Nombre De Points" Dans Les Tableaux De Corrélation ? - Forex Forum