indicateur stpmt
Publié : 10 sept. 2010, 11:04
salut tout le monde, j'aimrais savoir si quelqu'un utilise la stochastique pondéré a moyen terme dont voici le code pour MT4 :
//+------------------------------------------------------------------+
//| STPMT.mq4 |
//| FCognet |
//| |
//+------------------------------------------------------------------+
#property copyright "Eric Lefort"
#property link "http://www.pro-at.com"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 DimGray
#property indicator_color2 DimGray
#property indicator_color3 DimGray
#property indicator_color4 DimGray
#property indicator_color5 Red
#property indicator_color6 Blue
//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double STPMT[];
double STPMT_MA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
string short_name;
short_name="STPMT";
IndicatorShortName(short_name);
//---- indicators
IndicatorBuffers(6);
SetIndexBuffer(0, Buffer1);
SetIndexBuffer(1, Buffer2);
SetIndexBuffer(2, Buffer3);
SetIndexBuffer(3, Buffer4);
SetIndexBuffer(4, STPMT);
SetIndexBuffer(5, STPMT_MA);
SetIndexStyle(0, DRAW_LINE, STYLE_DOT);
SetIndexStyle(1, DRAW_LINE, STYLE_DOT);
SetIndexStyle(2, DRAW_LINE, STYLE_DOT);
SetIndexStyle(3, DRAW_LINE, STYLE_DOT);
SetIndexStyle(4, DRAW_LINE, EMPTY, 1);
SetIndexStyle(5, DRAW_LINE, EMPTY, 1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| iteration function |
//+------------------------------------------------------------------+
int start() {
int index = 0;
int counted_bars=IndicatorCounted();
int limit = Bars - counted_bars;
for(index=0;index<limit;index++) {
Buffer1[index] = iStochastic( NULL, 0, 5, 2, 2, MODE_SMA, 0, MODE_SIGNAL, index);
Buffer2[index] = iStochastic( NULL, 0, 14, 2, 2, MODE_SMA, 0, MODE_SIGNAL, index);
Buffer3[index] = iStochastic( NULL, 0, 45, 14, 2, MODE_SMA, 0, MODE_SIGNAL, index);
Buffer4[index] = iStochastic( NULL, 0, 75, 20, 2, MODE_SMA, 0, MODE_SIGNAL, index);
STPMT[index] = (4.1 * Buffer1[index] + 2.5 * Buffer2[index] + Buffer3[index] + 4 * Buffer4[index]) / 11.6;
}
for(index=0;index<limit;index++) {
STPMT_MA[index] = iMAOnArray(STPMT, 0, 9, 0, MODE_SMA, index);
}
return(0);
}