Bonjour,
J’aurais besoin de la conversion de cet indicateur RSI de Métatrader.
Merci beaucoup d’avance
#property copyright “Par pheniksss”
#property link “”
#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_levelcolor Orange
#property indicator_levelstyle 0
#property indicator_buffers 5
#property indicator_color1 White
#property indicator_color2 Black
#property indicator_color3 Black
#property indicator_color4 Red
#property indicator_color5 Aqua
#property indicator_width1 2
#property indicator_level1 20.0
#property indicator_level2 40.0
#property indicator_level3 60.0
#property indicator_width4 2
#property indicator_level4 80.0
extern int RSIPeriod = 14;
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
bool gi_100;
bool gi_104;
bool gi_108;
int g_window_112;
int init() {
string ls_0;
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(0, g_ibuf_80);
SetIndexStyle(1, DRAW_NONE);
SetIndexBuffer(1, g_ibuf_84);
SetIndexStyle(2, DRAW_NONE);
SetIndexBuffer(2, g_ibuf_88);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(3, g_ibuf_92);
SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(4, g_ibuf_96);
IndicatorShortName(ls_0);
SetIndexLabel(0, ls_0);
ls_0 = “RSI(” + RSIPeriod + “)”;
g_window_112 = WindowFind(“RSI Belkhayate”);
gi_108 = FALSE;
return (0);
}
int start() {
double ld_8;
double ld_16;
double ld_24;
double ld_32;
double ld_40;
int l_ind_counted_4 = IndicatorCounted();
if (Bars <= RSIPeriod) return (0);
if (l_ind_counted_4 < 1) for (int li_0 = 1; li_0 <= RSIPeriod; li_0++) g_ibuf_80[Bars – li_0] = 0.0;
li_0 = Bars – RSIPeriod – 1;
if (l_ind_counted_4 >= RSIPeriod) li_0 = Bars – l_ind_counted_4 – 1;
while (li_0 >= 0) {
ld_32 = 0.0;
ld_40 = 0.0;
if (li_0 == Bars – RSIPeriod – 1) {
for (int li_48 = Bars – 2; li_48 >= li_0; li_48–) {
ld_8 = Close[li_48] – (Close[li_48 + 1]);
if (ld_8 > 0.0) ld_40 += ld_8;
else ld_32 -= ld_8;
}
ld_24 = ld_40 / RSIPeriod;
ld_16 = ld_32 / RSIPeriod;
} else {
ld_8 = Close[li_0] – (Close[li_0 + 1]);
if (ld_8 > 0.0) ld_40 = ld_8;
else ld_32 = -ld_8;
ld_24 = ((g_ibuf_84[li_0 + 1]) * (RSIPeriod – 1) + ld_40) / RSIPeriod;
ld_16 = ((g_ibuf_88[li_0 + 1]) * (RSIPeriod – 1) + ld_32) / RSIPeriod;
}
g_ibuf_84[li_0] = ld_24;
g_ibuf_88[li_0] = ld_16;
if (ld_16 == 0.0) g_ibuf_80[li_0] = 0.0;
else g_ibuf_80[li_0] = 100.0 – 100.0 / (ld_24 / ld_16 + 1.0);
li_0–;
}
for (li_0 = Bars; li_0 >= 0; li_0–) {
g_ibuf_92[li_0] = g_ibuf_80[li_0];
g_ibuf_96[li_0] = g_ibuf_80[li_0];
if (g_ibuf_80[li_0] < 60.0 && g_ibuf_80[li_0] > 40.0) {
g_ibuf_96[li_0] = EMPTY_VALUE;
g_ibuf_92[li_0] = EMPTY_VALUE;
} else {
if (g_ibuf_80[li_0] >= 60.0) {
g_ibuf_96[li_0] = EMPTY_VALUE;
gi_100 = TRUE;
gi_104 = FALSE;
} else {
if (g_ibuf_80[li_0] <= 40.0) {
g_ibuf_92[li_0] = EMPTY_VALUE;
gi_104 = TRUE;
gi_100 = FALSE;
}
}
}
}
if (gi_104 == TRUE) {
ObjectCreate(“Couloir bas”, OBJ_RECTANGLE, g_window_112, Time[Bars], 60, Time[0], 20, 0, 0);
ObjectSet(“Couloir bas”, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(“Couloir bas”, OBJPROP_COLOR, FireBrick);
ObjectsRedraw();
} else {
if (gi_100 == TRUE) {
ObjectCreate(“Couloir haut”, OBJ_RECTANGLE, g_window_112, Time[Bars], 40, Time[0], 80, 0, 0);
ObjectSet(“Couloir haut”, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(“Couloir haut”, OBJPROP_COLOR, Green);
ObjectsRedraw();
}
}
if (g_ibuf_80[0] < 60.0 && g_ibuf_80[0] > 40.0) gi_108 = FALSE;
if (g_ibuf_80[0] >= 60.0 && g_ibuf_80[1] < 60.0 && gi_108 == FALSE) {
PlaySound(“tick.wav”);
Alert(“ACHAT RSI BEL “, Symbol());
gi_108 = TRUE;
}
if (g_ibuf_80[0] <= 40.0 && g_ibuf_80[1] > 40.0 && gi_108 == FALSE) {
PlaySound(“tick.wav”);
Alert(“VENTE RSI BEL “, Symbol());
gi_108 = TRUE;
}
ObjectsRedraw();
return (0);
}
int deinit() {
ObjectsDeleteAll();
return (0);