TRUE Forex

Просмотр кода форекс индикатора !MoneyLine.mq4

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow

extern bool Send.Mail = FALSE;
extern bool Sound.Alert = FALSE;
extern bool Show.Gauge = FALSE;
extern int myChartX = 10;
extern int myChartY = 10;
extern int myCorner = 1;
extern string myFont = "Courier New";
extern int myFontSize = 12;
extern int typeMoneyLine = 0;
extern int widthMoneyLine = 2;
extern color colorMoneyLine = Yellow;
extern color colorHead = Orange;
extern color colorUp = Lime;
extern color colorEq = Yellow;
extern color colorDn = Red;
extern bool Show.PriceBox = FALSE;
extern int myBoxWidth = 3;
int g_period_148 = 88;
string gs_unused_152 = "0=SMA,1=EMA,2=SMMA,3=LWMA";
int g_ma_method_160 = MODE_SMMA;
string gs_unused_164 = "0=CLOSE,1=OPEN,2=HIGH,3=LOW,4=MEDIAN,5=PP,6=WEIGHT";
int g_applied_price_172 = PRICE_CLOSE;
string gs_unused_176 = "MoneyLine © 2009";
int gi_unused_184 = 42495;
bool gi_unused_188 = FALSE;
double gd_192;
string gs_dummy_204;
string gs_212;
int g_acc_number_220 = 0;
int g_color_224 = Red;
string gs_unused_228 = "Font Size";
int g_fontsize_236 = 20;
string gs_unused_240 = "Font Type";
string gs_verdana_248 = "Verdana";
string g_text_256 = ">>> CHECKING ACCOUNT <<<";
string g_text_264 = ">>> AUTHORIZATION <<<";
string g_name_272 = "MoneyLine3";
string g_name_280 = "MoneyLine4";
double g_ibuf_288[];
double g_iclose_300;
double g_iclose_316;
double gd_324;
double gd_332;
bool g_bool_340;
bool g_bool_344;
datetime g_time_348;
int gi_352;
int g_index_356;
int gi_360 = 11;
int gi_364;
int gi_368;
int gi_372;
int gi_376;
int gi_unused_380;
int gi_unused_384;
int gi_unused_388;
string gs_dummy_392;
string gs_400;
string gs_dummy_408;
string gs_dummy_416;
string gs_dummy_424;
string gs_dummy_432;
string gs_dummy_440;
string gs_dummy_448;
string gs_dummy_456;
string gs_dummy_464;
string gs_dummy_472;
int g_color_480 = Blue;
string g_symbol_484;
string gs_492;
int gi_500;
int g_timeframe_504;
string gsa_512[15];
string gsa_516[15];
int gi_520 = 0;
int gi_524;
int gi_528;
int g_ind_counted_532;
bool gi_unused_536 = TRUE;
bool gi_540 = FALSE;

int init() {
   g_timeframe_504 = Period();
   gs_492 = TimeFrameToString(g_timeframe_504);
   g_symbol_484 = Symbol();
   gi_500 = Digits;
   gd_192 = Point;
   if (gi_500 == 5 || gi_500 == 3) {
      gi_500--;
      gd_192 = 10.0 * gd_192;
   }
   gs_212 = "MoneyLine" + g_period_148;
   gs_400 = "MoneyLine";
   g_time_348 = -1;
   if (myCorner == 0 || myCorner == 2) {
      gi_364 = 0;
      gi_368 = 0;
      gi_372 = 90;
      gi_376 = 150;
      gi_unused_380 = 100;
      gi_unused_384 = 90;
      gi_unused_388 = 90;
      gi_360 = 20;
   } else {
      gi_364 = 0;
      gi_368 = 0;
      gi_372 = 50;
      gi_376 = 0;
      gi_unused_380 = 10;
      gi_unused_384 = 10;
      gi_unused_388 = 10;
      gi_360 = 24;
   }
   SetIndexStyle(0, typeMoneyLine, STYLE_SOLID, widthMoneyLine, colorMoneyLine);
   SetIndexBuffer(0, g_ibuf_288);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   deinit();
   return (0);
}

void ObDeleteObjectsByPrefix(string as_0) {
   string l_name_16;
   int l_str_len_8 = StringLen(as_0);
   int li_12 = 0;
   while (li_12 < ObjectsTotal()) {
      l_name_16 = ObjectName(li_12);
      if (StringSubstr(l_name_16, 0, l_str_len_8) != as_0) {
         li_12++;
         continue;
      }
      ObjectDelete(l_name_16);
   }
}

int deinit() {
   ObDeleteObjectsByPrefix("MoneyLine");
   Comment("");
   return (0);
}

int start() {
   RefreshRates();
   ObjectDelete(g_name_272);
   ObjectDelete(g_name_280);
   gi_520++;
   g_ind_counted_532 = IndicatorCounted();
   if (!gi_540) gi_528 = 8000;
   else gi_528 = Bars - g_ind_counted_532;
   for (gi_524 = gi_528; gi_524 >= 0; gi_524--) {
      g_ibuf_288[gi_524] = iMA(NULL, 0, g_period_148, 0, g_ma_method_160, g_applied_price_172, gi_524);
      if (gi_524 > 100) gi_540 = TRUE;
   }
   if (Show.PriceBox) DoBox();
   if (Show.Gauge) DoShowGauge();
   DoAlert();
   ObjectsRedraw();
   return (0);
}

void DoAlert() {
   g_iclose_300 = iClose(g_symbol_484, 0, 0);
   g_iclose_316 = iClose(g_symbol_484, 0, 1);
   g_bool_340 = g_iclose_316 < g_ibuf_288[1] && g_iclose_300 >= g_ibuf_288[1];
   g_bool_344 = g_iclose_316 > g_ibuf_288[1] && g_iclose_300 <= g_ibuf_288[1];
   if (g_time_348 != Time[0]) {
      if (Sound.Alert) {
         if (g_bool_340) {
            g_time_348 = Time[0];
            Alert(g_symbol_484, "  ", " Price Crossed Above MoneyLine " + DoubleToStr(g_ibuf_288[1], gi_500));
         }
         if (g_bool_344) {
            g_time_348 = Time[0];
            Alert(g_symbol_484, "  ", " Price Crossed Below MoneyLine " + DoubleToStr(g_ibuf_288[1], gi_500));
         }
      }
      if (Send.Mail) {
         if (g_bool_340) {
            g_time_348 = Time[0];
            SendMail(g_symbol_484, " Price Crossed Above MoneyLine " + DoubleToStr(g_ibuf_288[1], gi_500));
         }
         if (g_bool_344) {
            g_time_348 = Time[0];
            SendMail(g_symbol_484, " Price Crossed Below MoneyLine " + DoubleToStr(g_ibuf_288[1], gi_500));
         }
      }
   }
}

void DoBox() {
   if (ObjectFind(gs_212 + "01") != 0) {
      ObjectCreate(gs_212 + "01", OBJ_ARROW, 0, Time[0], g_ibuf_288[1]);
      ObjectSet(gs_212 + "01", OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
      ObjectSet(gs_212 + "01", OBJPROP_COLOR, colorMoneyLine);
      ObjectSet(gs_212 + "01", OBJPROP_WIDTH, myBoxWidth);
      return;
   }
   ObjectMove(gs_212 + "01", 0, Time[0], g_ibuf_288[1]);
   ObjectSet(gs_212 + "01", OBJPROP_COLOR, colorMoneyLine);
}

void DoShowGauge() {
   gi_352 = 10;
   g_index_356 = 0;
   g_iclose_300 = iClose(g_symbol_484, g_timeframe_504, 0);
   gsa_512[g_index_356] = gs_400 + g_index_356;
   gsa_516[g_index_356] = fFill(gs_492 + " MoneyLine(" + DoubleToStr(g_period_148, 2) + ") +/-", gi_360);
   DoShowHead(g_index_356, colorHead);
   g_index_356++;
   gsa_512[g_index_356] = gs_400 + g_index_356;
   gd_324 = g_ibuf_288[1];
   gd_332 = (g_iclose_300 - gd_324) / gd_192;
   DoColor(gd_332, 0);
   gsa_516[g_index_356] = fFill("MoneyLine ", gi_360);
   DoShow(g_index_356, g_color_480);
}

void DoShowHead(int ai_0, color a_color_4) {
   ObjectCreate(gsa_512[ai_0], OBJ_LABEL, 0, Time[0], 0);
   ObjectSet(gsa_512[ai_0], OBJPROP_CORNER, myCorner);
   ObjectSet(gsa_512[ai_0], OBJPROP_XDISTANCE, gi_364 + myChartX);
   ObjectSet(gsa_512[ai_0], OBJPROP_YDISTANCE, gi_352 + myChartY);
   ObjectSetText(gsa_512[ai_0], gsa_516[ai_0], myFontSize, myFont, a_color_4);
   gi_352 += 20;
}

void DoShow(int ai_0, color a_color_4) {
   string l_name_8;
   string l_text_16;
   string l_name_24;
   string l_text_32;
   ObjectCreate(gsa_512[ai_0], OBJ_LABEL, 0, Time[0], 0);
   ObjectSet(gsa_512[ai_0], OBJPROP_CORNER, myCorner);
   ObjectSet(gsa_512[ai_0], OBJPROP_XDISTANCE, gi_368 + myChartX);
   ObjectSet(gsa_512[ai_0], OBJPROP_YDISTANCE, gi_352 + myChartY);
   ObjectSetText(gsa_512[ai_0], gsa_516[ai_0], myFontSize, myFont, a_color_4);
   if (ai_0 > 0) {
      l_name_8 = gsa_512[ai_0] + "val";
      l_text_16 = fFill(DoubleToStr(gd_324, gi_500), 7);
      ObjectCreate(l_name_8, OBJ_LABEL, 0, Time[0], 0);
      ObjectSet(l_name_8, OBJPROP_CORNER, myCorner);
      ObjectSet(l_name_8, OBJPROP_XDISTANCE, gi_372 + myChartX);
      ObjectSet(l_name_8, OBJPROP_YDISTANCE, gi_352 + myChartY);
      ObjectSetText(l_name_8, l_text_16, myFontSize, myFont, a_color_4);
      l_name_24 = gsa_512[ai_0] + "dif";
      l_text_32 = rtadjust(DoubleToStr(gd_332, 0));
      ObjectCreate(l_name_24, OBJ_LABEL, 0, Time[0], 0);
      ObjectSet(l_name_24, OBJPROP_CORNER, myCorner);
      ObjectSet(l_name_24, OBJPROP_XDISTANCE, gi_376 + myChartX);
      ObjectSet(l_name_24, OBJPROP_YDISTANCE, gi_352 + myChartY);
      ObjectSetText(l_name_24, l_text_32, myFontSize, myFont, a_color_4);
   }
   gi_352 += 20;
}

void DoColor(double ad_0, double ad_8) {
   if (ad_0 > ad_8) {
      g_color_480 = colorUp;
      return;
   }
   if (ad_0 < ad_8) {
      g_color_480 = colorDn;
      return;
   }
   g_color_480 = colorEq;
}

string fFill(string as_0, int ai_8) {
   string ls_unused_12;
   return (StringSubstr(as_0 + "                                         ", 0, ai_8));
}

void DoForbidden() {
   ObjectCreate(g_name_272, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(g_name_272, g_text_256, g_fontsize_236, gs_verdana_248, g_color_224);
   ObjectSet(g_name_272, OBJPROP_CORNER, 0);
   ObjectSet(g_name_272, OBJPROP_XDISTANCE, 5);
   ObjectSet(g_name_272, OBJPROP_YDISTANCE, 10);
   ObjectCreate(g_name_280, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(g_name_280, g_text_264, g_fontsize_236, gs_verdana_248, g_color_224);
   ObjectSet(g_name_280, OBJPROP_CORNER, 0);
   ObjectSet(g_name_280, OBJPROP_XDISTANCE, 5);
   ObjectSet(g_name_280, OBJPROP_YDISTANCE, g_fontsize_236 + 20);
}

string rtadjust(string as_0) {
   int l_str_len_8 = StringLen(as_0);
   if (l_str_len_8 != 5) {
      if (l_str_len_8 == 4) as_0 = " " + as_0;
      else {
         if (l_str_len_8 == 3) as_0 = "  " + as_0;
         else {
            if (l_str_len_8 == 2) as_0 = "   " + as_0;
            else
               if (l_str_len_8 == 1) as_0 = "    " + as_0;
         }
      }
   }
   return (as_0);
}

string TimeFrameToString(int ai_0) {
   string ls_ret_4;
   switch (ai_0) {
   case 1:
      ls_ret_4 = "M1";
      break;
   case 5:
      ls_ret_4 = "M5";
      break;
   case 15:
      ls_ret_4 = "M15";
      break;
   case 30:
      ls_ret_4 = "M30";
      break;
   case 60:
      ls_ret_4 = "H1";
      break;
   case 240:
      ls_ret_4 = "H4";
      break;
   case 1440:
      ls_ret_4 = "D1";
      break;
   case 10080:
      ls_ret_4 = "W1";
      break;
   case 43200:
      ls_ret_4 = "MN";
   }
   return (ls_ret_4);
}

Комментарии к исходному коду форекс индикатора !MoneyLine.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.

  • X
  • 0% загружено
« индикатор !MY TMA+Channel_End_Point.mq4
индикатор !MoneyLine2.1.mq4 »