Simplification Visuel
Forex Forum > Français > Ressources > Logiciels et matériels
imperatorfr
Bonjour,

J'utilise un CCI en ut30. Je l'utilise pour sa voir dans quel sens je vais rentré en UT5 ou ut1.

Pour un simple soucis de visibilité je voudrais que quand mon CCI ut30 est à la hausse ça désine une barre Bleu et quand il est à la baisse je voudrais qu'il dessine une ligne rouge (ou bien un Histograme)



Par exemple sur cette image vous voyez 2 indicateur, en haut le miens (qui foire complètement comme vous pouvez le constater)
Et en bas un exemple de se que je voudrais, mais avec seulement des barres Bleu et rouge.

Voici mon code

CODE

//+------------------------------------------------------------------+
//|                                                      IMPEM30.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.mataf.net |
//+------------------------------------------------------------------+
#property copyright "Imperatorfr"
#property link      "http://www.mataf.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double TrendUp[];
double TrendDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
  SetIndexBuffer(0, TrendUp);
  SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
  SetIndexBuffer(1, TrendDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i;
   int    counted_bars=IndicatorCounted();
   int limit;
   double T3Current, T3Previous;
  
   T3Current=iCustom(NULL,30,"ImperINDIC",PRICE_CLOSE,i);
  
   T3Previous=iCustom(NULL,30,"ImperINDIC",PRICE_CLOSE,i+1);
  
  
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(i=0; i<limit; i++)
      
     if(T3Previous<T3Current) TrendUp[i]=1;
     if(T3Previous<T3Current) TrendDown[i]=1;



  
//----
   return(0);
  }
//+------------------------------------------------------------------+
dieupip
pour faire avancer le schmilblik :
la variable i c'est quoi dans :

TrendUp[i]=1;

? ( = pas utilisée avant tongue.gif )
imperatorfr
Aucune idée :/ en fait j'ai copié ça d'un autre script, se doit être la chandelle en cour non ?
Zed
CITATION(imperatorfr @ Dec 22 2006, 21:53) [snapback]11201[/snapback]

Aucune idée :/ en fait j'ai copié ça d'un autre script, se doit être la chandelle en cour non ?



salut impé

essaye ca ca devrai aller !


//+------------------------------------------------------------------+
//| IMPEM30.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.mataf.net |
//+------------------------------------------------------------------+
#property copyright "Imperatorfr"
#property link "http://www.mataf.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double TrendUp[];
double TrendDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexBuffer(0, TrendUp);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexBuffer(1, TrendDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
double T3Current, T3Previous;
T3Current=iCustom(NULL,30,"ImperINDIC",PRICE_CLOSE,0);
T3Previous=iCustom(NULL,30,"ImperINDIC",PRICE_CLOSE,1);


//---- check for possible errors
if(counted_bars<100) return(-1);

for(i=1000; i<0; i--){
if(T3Previous<T3Current) {TrendUp[i]=1;TrendDown[i]=0;}
if(T3Previous<T3Current) {TrendDown[i]=1;TrendUp[i]=0;}
}



//----
return(0);
}
//+------------------------------------------------------------------+



voila Joyeuses fête a tous !


zed
imperatorfr
Merci de t'être penché sur mon problème, mais ça ne marche pas :/

Il me mettait une erreur quand je voulais compilé :

J'ai donc remplacé "counted_bars" par "Bars"

Mais malgrès ça il ne dessine rien :/
Zed
CITATION(imperatorfr @ Dec 27 2006, 23:53) [snapback]11271[/snapback]

Merci de t'être penché sur mon problème, mais ça ne marche pas :/

Il me mettait une erreur quand je voulais compilé :

J'ai donc remplacé "counted_bars" par "Bars"

Mais malgrès ça il ne dessine rien :/


oups en effet , en relisant le code, les condition de de trend up et down sont les memes.
il faut donc coriger!!
remplace le
for(i=1000; i<0; i--){
if(T3Previous<T3Current) {TrendUp[i]=1;TrendDown[i]=0;}
if(T3Previous<T3Current) {TrendDown[i]=1;TrendUp[i]=0;}
}

par for(i=1000; i<0; i--){
if(T3Previous<T3Current) {TrendUp[i]=1;TrendDown[i]=0;}
if(T3Previous>T3Current) {TrendDown[i]=1;TrendUp[i]=0;}
}

si cela ne fonctionne par ainsi , l erreur doit venir de ton indicateur "imperINDIC".
La boucle de calcul de chaque bougie doit etre de la forme
for(i=1000; i<0; i--){
traitement ici
}
et non de la forme
for(i=0; i>1000; i++){
traitement ici
}

enfin , si tu veux .envoie moi ton indic par mail ou poste le ici , je te le corrigerai. c'est l histoire de 5 min.


@++ zed
imperatorfr
Merci pour ton aide smile.gif voici le code de l'indic :
J'ai effectué tout les changements que tu avais demandé, mais celà n'a rien changé :/

CODE

//+------------------------------------------------------------------+
//|                                                       T3 CCI.mq4 |
//|                                                        FX Sniper |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "FX Sniper:  T3-CCI :-)"
#property link      "http://dunno.com  :-)/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property  indicator_color2  Lime
#property  indicator_color3  Red

extern int CCI_Period = 14;
extern int T3_Period = 5;
extern double b = 0.618;

double e1,e2,e3,e4,e5,e6;
double c1,c2,c3,c4;
double n,w1,w2,b2,b3;
double cci[];
double cciHup[];
double cciHdn[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators setting
    IndicatorBuffers(8);

    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
    SetIndexStyle(1,DRAW_HISTOGRAM,0,1);
    SetIndexStyle(2,DRAW_HISTOGRAM,0,1);
        
    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
    IndicatorShortName("FX Sniper's T3-CCI: "+CCI_Period);
    
    SetIndexBuffer(0,cci);
    SetIndexBuffer(1,cciHup);
    SetIndexBuffer(2,cciHdn);
    SetIndexLabel(0,"T3-CCI");
  

//---- variable reset

    b2=b*b;
    b3=b2*b;
    c1=-b3;
    c2=(3*(b2+b3));
    c3=-3*(2*b2+b+b3);
    c4=(1+3*b+b3+3*b2);
    n=T3_Period;

    if (n<1) n=1;
    n = 1 + 0.5*(n-1);
    w1 = 2 / (n + 1);
    w2 = 1 - w1;
    
//----
    return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
  
//---- indicator calculation
//for(int i=limit; i>=0; i--)
    
    for(int i=1000; i<=0; i--)
    {
    
    cci[i]= iCCI(NULL,0,CCI_Period, PRICE_TYPICAL ,i);

    
        e1 = w1*cci[i] + w2*e1;
        e2 = w1*e1 + w2*e2;
        e3 = w1*e2 + w2*e3;
        e4 = w1*e3 + w2*e4;
        e5 = w1*e4 + w2*e5;
        e6 = w1*e5 + w2*e6;
        
        cci[i] = c1*e6 + c2*e5 + c3*e4 + c4*e3;
  
     if (cci[i] >= 0 )
      cciHup[i] = cci[i];
     else
      cciHup[i] = 0;
    
     if (cci[i] < 0 )
      cciHdn[i] = cci[i];
     else
      cciHdn[i]=0;
  
        
        
    }  
//----
   return(0);
  }
//+------------------------------------------------------------------+


Encore Merci
Zed
salut impé,

voila ca fonctionne ,en fait l indic que tu appelais demander 3 parametres indispensables...

voila le code :

//+------------------------------------------------------------------+
//| IMPEM30.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.mataf.net |
//+------------------------------------------------------------------+
#property copyright "Imperatorfr"
#property link "http://www.mataf.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- buffers
double TrendUp[];
double TrendDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators

SetIndexStyle(0, DRAW_HISTOGRAM, 0, 2);
SetIndexBuffer(0, TrendUp);
SetIndexStyle(1, DRAW_HISTOGRAM, 0, 2);
SetIndexBuffer(1, TrendDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
double T3Current, T3Previous;
double counted_bars = Bars;
//---- check for possible errors
if(counted_bars<100) return(-1);
for(i=0; i<1000; i++){
T3Current=iCustom(NULL,0,"ImperINDIC",15,5,0.618,0,i);
T3Previous=iCustom(NULL,0,"ImperINDIC",15,5,0.618,0,i+1);
if(T3Previous<T3Current) {TrendUp[i]=1;TrendDown[i]=0;}
if(T3Previous>T3Current) {TrendDown[i]=1;TrendUp[i]=0;}
}



//----
return(0);
}
//+------------------------------------------------------------------+

Voila Bon trade.

zed
imperatorfr
Trop cool je te remercie smile.gif

merci l'amis mataf_wink.gif