Bonsoir à tous,
J'ai écrit l'indicateur ci après en MQL4.
En fait, je souhaiterais qu'une barre verticale s'affiche lorsque le cours est > à une moyenne mobile.
Je pensais la mise en place facile, mais ce n'est pas le cas.
Compilation ok, affichage fenètre séparée ok, mais au final... rien ne s'affiche dans la fenètre de l'indicateur.
Une idée ? Merci.
Le code..
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green
#property indicator_width1 1
//---- indicator parameters
extern int ema = 8;
//---- indicator buffers
double emaBuff[];
int emaTrend[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexShift(0,0);
SetIndexDrawBegin(0,emaTrend);
//---- indicator buffers mapping
SetIndexBuffer(0,emaTrend);
return(0);
}
//+------------------------------------------------------------------+
//| Exponential Moving Average |
//+------------------------------------------------------------------+
int start()
{
if(Bars<= ema) return(0);
int i, countedBars, limit;
countedBars=IndicatorCounted();
if(countedBars>0) countedBars--;
limit = Bars - countedBars;
for( i=0; i<=limit; i++)
{
emaBuff[i] = iMA(0,0,ema,0,1, PRICE_CLOSE,i);
emaTrend[i] = 0;
if (Close[i] > emaBuff[i])
emaTrend[i] = 1;
Alert("i = " + i + "et cloture : " + Close[i]);
Alert("emaBuff = " + emaBuff[i]);
Alert("Trend = " + emaTrend[i]);
}
return(0);
}
//+------------------------------------------------------------------+
Affichage des résultats 1 à 2 sur 2
-
09/04/2012, 21h06 #1Nouveau membre
- Date d'inscription
- April 2012
- Messages
- 2
- Pouvoir de réputation
- 3
Rien ne s'affiche !
-
10/04/2012, 19h36 #2Membre Performance
- Date d'inscription
- April 2009
- Messages
- 179
- Pouvoir de réputation
- 11
Bonsoir,
la version suivante fonctionne. Remarque les arguments de iMA() et plus particulièrement Symbol() ainsi que le type double de ton buffer d'affichage.
Le reste des modifications ne sont que fioritures.
Cordialement, Guonzo.Code://---- indicator settings #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Green #property indicator_width1 1 //---- indicator parameters extern int ema = 8; //---- indicator buffers //double emaBuff[]; double emaTrend[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexShift(0,0); //SetIndexDrawBegin(0,emaTrend); //---- indicator buffers mapping SetIndexBuffer(0,emaTrend); return(0); } //+------------------------------------------------------------------+ //| Exponential Moving Average | //+------------------------------------------------------------------+ int start() { if(Bars<= ema) return(0); int i, countedBars, limit; countedBars=IndicatorCounted(); if(countedBars>0) countedBars--; limit = Bars - countedBars; for( i=0; i<=limit; i++) { double val; val = iMA(Symbol(),0,ema,0,MODE_SMA, PRICE_CLOSE,i); //emaTrend[i] = 0; if (Close[i] > val) emaTrend[i] = 1.0; else emaTrend[i] = 0.0; /*Alert("i = " + i + "et cloture : " + Close[i]); Alert("emaBuff = " + emaBuff[i]); Alert("Trend = " + emaTrend[i]);*/ } return(0); } //+------------------------------------------------------------------+
Discussions similaires
-
Indicateur qui affiche l'écart
Par manu dans le forum ProgrammationRéponses: 3Dernier message: 24/07/2009, 16h40
![]() |
|
Mercredi 20 Mars 2013
Trader-Forex.fr en RSS
LinkBack URL
About LinkBacks
Répondre avec citation
