hi
here is trend +stops mt4 coding
--------------------------
this helps to see what goes in-this is not afl
-----------------------------------------------
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 White
#property indicator_color4 Lime
#property indicator_color5 Red
#property indicator_color6 Lime
#property indicator_color7 Red
#import "Hawkeye2012MT.dll"
int xCreateFunc2012();
int xDestroyFunc2012(int a0);
void H9_AddPriceData(int a0, double a1, double a2, double a3, double a4, int a5, int a6, int a7, int a8, int a9, double a10, int a11);
int H9_HSB(int a0, int a1, double a2, double a3, double a4);
double H9_HSBFSV(int a0, int a1, double a2, double a3, double a4);
double H9_HSBV(int a0, int a1, double a2, double a3, double a4);
double H9_HTV(int a0, int a1);
int H9_HT(int a0, int a1, double a2);
#import
extern string Trend_Speed = "Conservative";
extern string Pull_in_Stop = "On";
extern int Pull_in_Count = 15;
extern string Pull_in_Stop_to = "a";
extern string Stops = "On";
extern string Trend = "On";
extern string Trend_Alerts = "On";
extern string Stop_Alerts = "Off";
double g_ibuf_136[];
double g_ibuf_140[];
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
double g_ibuf_160[];
int gi_164;
string gs_168;
double gd_176;
int init() {
SetIndexShift(0, 0);
SetIndexShift(1, 0);
SetIndexShift(2, 0);
SetIndexShift(3, 0);
SetIndexShift(4, 0);
SetIndexShift(5, 0);
SetIndexShift(6, 0);
SetIndexDrawBegin(0, 0);
SetIndexDrawBegin(1, 0);
SetIndexDrawBegin(2, 0);
SetIndexDrawBegin(3, 0);
SetIndexDrawBegin(4, 0);
SetIndexDrawBegin(5, 0);
SetIndexDrawBegin(6, 0);
SetIndexBuffer(0, g_ibuf_136);
SetIndexBuffer(1, g_ibuf_140);
SetIndexBuffer(2, g_ibuf_144);
SetIndexBuffer(3, g_ibuf_148);
SetIndexBuffer(4, g_ibuf_152);
SetIndexBuffer(5, g_ibuf_156);
SetIndexBuffer(6, g_ibuf_160);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 108);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 108);
SetIndexStyle(2, DRAW_ARROW);
SetIndexArrow(2, 108);
SetIndexStyle(3, DRAW_ARROW);
SetIndexArrow(3, SYMBOL_STOPSIGN);
SetIndexStyle(4, DRAW_ARROW);
SetIndexArrow(4, SYMBOL_STOPSIGN);
SetIndexStyle(5, DRAW_LINE, STYLE_SOLID);
SetIndexStyle(6, DRAW_LINE, STYLE_SOLID);
SetIndexLabel(0, "Hawkeye Trend");
SetIndexLabel(1, "Hawkeye Trend");
SetIndexLabel(2, "Hawkeye Trend");
SetIndexLabel(3, "Hawkeye FarStop");
SetIndexLabel(4, "Hawkeye FarStop");
SetIndexLabel(5, "Hawkeye Barrier");
SetIndexLabel(6, "Hawkeye Barrier");
gi_164 = xCreateFunc2012();
switch (Period()) {
case PERIOD_M1:
gs_168 = "1 min";
break;
case PERIOD_M5:
gs_168 = "5 mins";
break;
case PERIOD_M15:
gs_168 = "15 mins";
break;
case PERIOD_M30:
gs_168 = "30 mins";
break;
case PERIOD_H1:
gs_168 = "1 hour";
break;
case PERIOD_H4:
gs_168 = "4 hours";
break;
case PERIOD_D1:
gs_168 = "Daily";
break;
case PERIOD_W1:
gs_168 = "Weekly";
break;
case PERIOD_MN1:
gs_168 = "Monthly";
}
return (0);
}
int deinit() {
xDestroyFunc2012(gi_164);
return (0);
}
int start() {
int li_0;
double ld_4;
double ld_12;
double ld_20;
double ld_28;
double ld_36;
double ld_44;
double ld_52;
double ld_60;
double ld_68;
int li_76;
double ld_88;
double ld_96;
int li_104;
if (AccountNumber() > 0) {
li_0 = AccountNumber();
if (li_0 > 99999999) li_0 -= 100000000 * (li_0 / 100000000);
ld_68 = 2;
li_76 = Bars - IndicatorCounted();
if (StringSubstr(Trend_Speed, 0, 1) == "c" || StringSubstr(Trend_Speed, 0, 1) == "C") ld_4 = 2.0;
if (StringSubstr(Trend_Speed, 0, 1) == "n" || StringSubstr(Trend_Speed, 0, 1) == "N") ld_4 = 1.625;
if (StringSubstr(Trend_Speed, 0, 1) == "a" || StringSubstr(Trend_Speed, 0, 1) == "A") ld_4 = 1.25;
if (StringSubstr(Trend_Speed, 0, 1) == "c" || StringSubstr(Trend_Speed, 0, 1) == "C") ld_12 = 2.5;
else ld_12 = 2.25;
for (int li_80 = Bars; li_80 > 0; li_80--) {
H9_AddPriceData(gi_164, Open[li_80], High[li_80], Low[li_80], Close[li_80], Volume[li_80], Time[li_80], Period(), Period(), 2, Point, Bars - li_80);
if (Stops == "On" || Stops == "ON" || Stops == "on" || Stops == "oN") {
ld_20 = H9_HSB(gi_164, li_0, ld_4, ld_12, ld_4);
ld_52 = H9_HSBFSV(gi_164, li_0, ld_4, ld_12, ld_4);
if (StringSubstr(Pull_in_Stop_to, 0, 1) == "a" || StringSubstr(Pull_in_Stop_to, 0, 1) == "A") ld_68 = 1.25;
if (StringSubstr(Pull_in_Stop_to, 0, 1) == "n" || StringSubstr(Pull_in_Stop_to, 0, 1) == "N") ld_68 = 1.625;
ld_60 = H9_HSBFSV(gi_164, li_0, ld_68, ld_12, 2.0);
if (ld_20 != gd_176) {
ld_28 = 0;
ld_36 = 0;
ld_44 = 0;
}
ld_28 += 1.0;
td_84 = H9_HSB(gi_164, li_0, ld_68, ld_12, ld_68);
if (Pull_in_Stop == "On" || Pull_in_Stop == "ON" || Pull_in_Stop == "on" || Pull_in_Stop == "oN" || ld_4 == 2.0 || ld_4 == 1.625) {
if (ld_20 == 1.0) {
if (ld_28 >= Pull_in_Count && td_84 == 1) ld_36 = 1;
if (ld_36 == 1.0) g_ibuf_148[li_80] = ld_60;
if (ld_36 == 0.0) g_ibuf_148[li_80] = ld_52;
}
if (ld_20 == -1.0) {
if (ld_28 >= Pull_in_Count && td_84 == -1) ld_44 = 1;
if (ld_44 == 1.0) g_ibuf_152[li_80] = ld_60;
if (ld_44 == 0.0) g_ibuf_152[li_80] = ld_52;
}
} else {
if (ld_20 == 1.0) g_ibuf_148[li_80] = ld_52;
if (ld_20 == -1.0) g_ibuf_152[li_80] = ld_52;
}
ld_88 = H9_HSBV(gi_164, li_0, ld_4, ld_12, ld_4);
if (ld_20 == 1.0) g_ibuf_156[li_80] = ld_88;
if (ld_20 == -1.0) g_ibuf_160[li_80] = ld_88;
}
if (Trend == "On" || Trend == "ON" || Trend == "on" || Trend == "oN") {
ld_96 = H9_HTV(gi_164, li_0);
li_104 = H9_HT(gi_164, li_0, ld_4);
if (li_104 == 1) {
g_ibuf_136[li_80] = ld_96;
g_ibuf_140[li_80] = EMPTY_VALUE;
g_ibuf_144[li_80] = EMPTY_VALUE;
} else {
if (li_104 == -1) {
g_ibuf_136[li_80] = EMPTY_VALUE;
g_ibuf_140[li_80] = ld_96;
g_ibuf_144[li_80] = EMPTY_VALUE;
} else {
if (li_104 == 0) {
g_ibuf_136[li_80] = EMPTY_VALUE;
g_ibuf_140[li_80] = EMPTY_VALUE;
g_ibuf_144[li_80] = ld_96;
}
}
}
}
gd_176 = ld_20;
}
if (Stop_Alerts == "On" || Stop_Alerts == "ON" || Stop_Alerts == "on" || Stop_Alerts == "oN") {
if (li_76 == 2) {
if (g_ibuf_160[1] != EMPTY_VALUE && g_ibuf_160[2] == EMPTY_VALUE) Alert("Hawkeye Barrier has turned Red: ", Symbol(), "-", gs_168);
if (g_ibuf_156[1] != EMPTY_VALUE && g_ibuf_156[2] == EMPTY_VALUE) Alert("Hawkeye Barrier has turned Green: ", Symbol(), "-", gs_168);
}
}
if (Trend_Alerts == "On" || Trend_Alerts == "ON" || Trend_Alerts == "on" || Trend_Alerts == "oN") {
if (li_76 == 2) {
if (g_ibuf_136[1] != EMPTY_VALUE && g_ibuf_136[2] == EMPTY_VALUE) Alert("Hawkeye Trend has turned Green: ", Symbol(), "-", gs_168);
if (g_ibuf_140[1] != EMPTY_VALUE && g_ibuf_140[2] == EMPTY_VALUE) Alert("Hawkeye Trend has turned Red: ", Symbol(), "-", gs_168);
}
}
if (li_76 == 2) gd_176 = ld_20;
}
return (0);
}