Good day,
Can anyone help get this code to work. It should show an X above or below candles. I also want to have ‘dots’ instead of X’s.
Please help. Thank you.
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Yellow
#property indicator_color3 Crimson
extern bool soundAlerts = TRUE;
extern bool emailAlerts = FALSE;
extern int length = 20;
int Gi_88 = 0;
int G_ma_method_92 = MODE_LWMA;
int G_applied_price_96 = PRICE_CLOSE;
double Gd_100 = 2.0;
bool Gi_108 = TRUE;
int Gi_unused_112 = 48;
int Gi_unused_116 = 38;
bool Gi_unused_120 = FALSE;
bool Gi_unused_124 = FALSE;
bool Gi_unused_128 = FALSE;
bool Gi_unused_132 = FALSE;
double G_ibuf_136[];
double G_ibuf_140[];
double G_ibuf_144[];
double G_ibuf_148[];
int Gi_152;
string Gs_156;
datetime G_time_164 = 0;
string GetTimeFrameStr() {
string timeframe_0;
switch (Period()) {
case PERIOD_M1:
timeframe_0 = "M1";
break;
case PERIOD_M5:
timeframe_0 = "M5";
break;
case PERIOD_M15:
timeframe_0 = "M15";
break;
case PERIOD_M30:
timeframe_0 = "M30";
break;
case PERIOD_H1:
timeframe_0 = "H1";
break;
case PERIOD_H4:
timeframe_0 = "H4";
break;
case PERIOD_D1:
timeframe_0 = "D1";
break;
case PERIOD_W1:
timeframe_0 = "W1";
break;
case PERIOD_MN1:
timeframe_0 = "MN1";
break;
default:
timeframe_0 = Period();
}
return (timeframe_0);
}
int init() {
IndicatorBuffers(4);
if ((!SetIndexBuffer(0, G_ibuf_136)) && (!SetIndexBuffer(1, G_ibuf_140)) && (!SetIndexBuffer(2, G_ibuf_144)) && (!SetIndexBuffer(3, G_ibuf_148))) Print("cannot set indicator buffers!");
if (Gi_108) {
SetIndexStyle(0, DRAW_ARROW);
SetIndexStyle(1, DRAW_ARROW);
SetIndexStyle(2, DRAW_ARROW);
SetIndexArrow(0, 1);
SetIndexArrow(1, 1);
SetIndexArrow(2, 1);
} else {
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexStyle(2, DRAW_LINE);
}
Gi_152 = length + MathFloor(MathSqrt(length));
SetIndexDrawBegin(0, Gi_152);
SetIndexDrawBegin(1, Gi_152);
SetIndexDrawBegin(2, Gi_152);
IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1.0);
IndicatorShortName("SignalCross(" + length + ")");
SetIndexLabel(0, "SignalCross");
Gs_156 = Symbol() + " (" + GetTimeFrameStr() + "): ";
return (0);
}
int start() {
double ima_on_arr_8;
bool Li_28;
bool Li_32;
int Li_16 = IndicatorCounted();
if (Li_16 < 0) return (-1);
if (Li_16 == 0) {
for (int Li_20 = 1; Li_20 <= Gi_152; Li_20++) G_ibuf_148[Bars - Li_20] = 0;
for (Li_20 = 1; Li_20 <= length; Li_20++) {
G_ibuf_136[Bars - Li_20] = 0;
G_ibuf_140[Bars - Li_20] = 0;
G_ibuf_144[Bars - Li_20] = 0;
}
}
if (Li_16 > 0) Li_16--;
int Li_24 = Bars - Li_16;
for (Li_20 = 0; Li_20 < Li_24; Li_20++) {
G_ibuf_148[Li_20] = 2.0 * iMA(NULL, 0, MathFloor(length / Gd_100), Gi_88, G_ma_method_92, G_applied_price_96, Li_20) - iMA(NULL, 0, length, Gi_88, G_ma_method_92,
G_applied_price_96, Li_20);
}
double ima_on_arr_0 = iMAOnArray(G_ibuf_148, 0, MathFloor(MathSqrt(length)), 0, G_ma_method_92, 0);
for (Li_20 = 1; Li_20 < Li_24; Li_20++) {
ima_on_arr_8 = iMAOnArray(G_ibuf_148, 0, MathFloor(MathSqrt(length)), 0, G_ma_method_92, Li_20);
if (ima_on_arr_8 > ima_on_arr_0) {
G_ibuf_136[Li_20] = EMPTY_VALUE;
G_ibuf_140[Li_20] = EMPTY_VALUE;
G_ibuf_144[Li_20] = ima_on_arr_8;
G_ibuf_144[Li_20 - 1] = ima_on_arr_0;
} else {
if (ima_on_arr_8 < ima_on_arr_0) {
G_ibuf_136[Li_20] = ima_on_arr_8;
G_ibuf_136[Li_20 - 1] = ima_on_arr_0;
G_ibuf_140[Li_20] = EMPTY_VALUE;
G_ibuf_144[Li_20] = EMPTY_VALUE;
} else {
G_ibuf_136[Li_20] = -1;
G_ibuf_140[Li_20] = ima_on_arr_8;
G_ibuf_144[Li_20 - 1] = ima_on_arr_0;
G_ibuf_144[Li_20] = -1;
}
}
ima_on_arr_0 = ima_on_arr_8;
}
if (BarChanged()) {
Li_28 = FALSE;
Li_32 = FALSE;
if (G_ibuf_144[2] > 0.0 && G_ibuf_144[2] < EMPTY_VALUE) Li_28 = TRUE;
if (G_ibuf_136[2] > 0.0 && G_ibuf_136[2] < EMPTY_VALUE) Li_32 = TRUE;
if (Li_32 && G_ibuf_144[1] > 0.0 && G_ibuf_144[1] < EMPTY_VALUE) {
if (soundAlerts) Alert("Short trade for " + Symbol());
if (emailAlerts) SendMail("SignalCross Sell signal", "Short trade for " + Symbol());
}
if (Li_28 && G_ibuf_136[1] > 0.0 && G_ibuf_136[1] < EMPTY_VALUE) {
if (soundAlerts) Alert("Long trade for " + Symbol());
if (emailAlerts) SendMail("SignalCross Buy signal", "Long trade for " + Symbol());
}
}
return (0);
}
int BarChanged() {
if (G_time_164 != Time[0]) {
G_time_164 = Time[0];
return (1);
}
return (0);
}