Daily Forex Signal

Download script
Author: Copyright � 2009, MetaQuotes Software Corp.
Daily Forex Signal

System Overview

The Daily Forex Signal is an automated technical analysis tool designed for the MetaTrader 4 platform. Its primary purpose is to scan multiple major and minor currency pairs simultaneously, evaluate current market trends across various timeframes, and provide visual "Buy" or "Sell" signals directly on the user's dashboard.

Core Logic & Functionality

The script operates through a multi-layered verification process to ensure that signals are based on consistent market momentum rather than isolated price spikes.

1. Access Control & Security

The tool includes an integrated expiration system. Before performing any analysis, the script checks the current date against a hardcoded limit (Year 2090, Month 4, Day 30). If the current date exceeds this threshold, the system will trigger an alert notification informing the user that the service has expired and providing contact information for renewal.

2. Multi-Timeframe Trend Analysis

To determine the strength of a market move, the script analyzes four different timeframes: 30-minute (M30), 1-hour (H1), 4-hour (H4), and Daily (D1). It uses Exponential Moving Averages (EMA) to identify the trend. The logic looks for "confluence," meaning it seeks instances where the short-term averages are consistently higher or lower than the long-term averages across all four periods simultaneously.

3. Momentum & Volatility Filters

Beyond simple trend lines, the script applies several secondary filters to confirm a signal's reliability:

  • RSI (Relative Strength Index): Used to ensure the market has sufficient momentum (checking if it is above or below the 50-level).
  • MACD (Moving Average Convergence Divergence): Used to verify the direction of price velocity across different settings.
  • Crossover Detection: The script monitors "crossings" on the 30-minute chart to ensure that a trend is currently active and not stagnant.

4. Dynamic Signal Generation

The script categorizes signals into two primary types based on the alignment of the data:

  • Primary Signals: These occur when all timeframes align perfectly with RSI and MACD indicators confirming a strong, high-confidence move. In these cases, the script identifies specific price points from the previous day's high or low to suggest a Take Profit (TP) level.
  • Secondary Signals: If the perfect alignment isn't met but the trend is still dominant across most timeframes, the script calculates a "neutral" target based on a mathematical average of the previous day's price action (High, Low, and Close).

5. User Interface & Alerts

The tool automates the visual organization of this data for the trader:

  • Real-time Dashboard: It creates a clean visual display showing the Currency Pair, the Signal Type (Buy/Sell), and the calculated Take Profit level.
  • Dynamic Coloring: Signals are color-coded for instant recognition (e.g., Lime/Green for Buy signals and Red for Sell signals).
  • Spread Monitoring: The script tracks the current "spread" (the cost of entering a trade) to ensure it provides accurate decimal formatting based on the liquidity of the specific currency pair being viewed.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each bar
Indicators Used
Moving average indicatorRelative strength indexMACD HistogramStochastic oscillator
Miscellaneous
It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
Daily Forex Signal
//+------------------------------------------------------------------+
//|                                           Daily Forex Signal.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window

int init() {
   IndicatorShortName("Daily Forex Signal");
   return (0);
}

int deinit() {
   ObjectsDeleteAll(1, OBJ_LABEL);
   return (0);
}

int start() {
   int li_0 = 2090;
   int li_4 = 4;
   int li_8 = 30;
   string ls_12 = "admin@valasssp.com";
   string ls_20 = "Daily Forex Signal";
   if (TimeYear(Time[0]) > li_0) {
      Alert(ls_20 + " has expired. ", "Please contact" + ls_12);
      return (0);
   }
   if (TimeYear(Time[0]) == li_0 && TimeMonth(Time[0]) > li_4) {
      Alert(ls_20 + " has expired. ", "Please contact" + ls_12);
      return (0);
   }
   if (TimeYear(Time[0]) == li_0 && TimeMonth(Time[0]) == li_4 && TimeDay(Time[0]) > li_8) {
      Alert(ls_20 + " has expired. ", "Please contact" + ls_12);
      return (0);
   }
   alerts("EURUSD", "label-01", "arrow-01", "ttp-01", "tp-01", "act-01", 2, 38);
   alerts("GBPUSD", "label-02", "arrow-02", "ttp-02", "tp-02", "act-02", 2, 56);
   alerts("AUDUSD", "label-03", "arrow-03", "ttp-03", "tp-03", "act-03", 2, 74);
   alerts("NZDUSD", "label-04", "arrow-04", "ttp-04", "tp-04", "act-04", 2, 92);
   alerts("EURGBP", "label-05", "arrow-05", "ttp-05", "tp-05", "act-05", 2, 128);
   alerts("USDJPY", "label-06", "arrow-06", "ttp-06", "tp-06", "act-06", 225, 38);
   alerts("EURJPY", "label-07", "arrow-07", "ttp-07", "tp-07", "act-07", 225, 56);
   alerts("CHFJPY", "label-08", "arrow-08", "ttp-08", "tp-08", "act-08", 225, 74);
   alerts("AUDJPY", "label-09", "arrow-09", "ttp-09", "tp-09", "act-09", 225, 92);
   alerts("CADJPY", "label-10", "arrow-10", "ttp-10", "tp-10", "act-10", 225, 110);
   alerts("GBPJPY", "label-11", "arrow-11", "ttp-11", "tp-11", "act-11", 225, 128);
   alerts("EURCHF", "label-12", "arrow-12", "ttp-12", "tp-12", "act-12", 480, 38);
   alerts("USDCHF", "label-13", "arrow-13", "ttp-13", "tp-13", "act-13", 480, 56);
   alerts("GBPCHF", "label-14", "arrow-14", "ttp-14", "tp-14", "act-14", 480, 74);
   alerts("CADCHF", "label-15", "arrow-15", "ttp-15", "tp-15", "act-15", 480, 92);
   alerts("NZDCHF", "label-16", "arrow-16", "ttp-16", "tp-16", "act-16", 480, 110);
   alerts("AUDCHF", "label-17", "arrow-17", "ttp-17", "tp-17", "act-17", 480, 128);
   alerts("USDCAD", "label-18", "arrow-18", "ttp-18", "tp-18", "act-18", 700, 38);
   alerts("AUDCAD", "label-19", "arrow-19", "ttp-19", "tp-19", "act-19", 700, 56);
   alerts("EURCAD", "label-20", "arrow-20", "ttp-20", "tp-20", "act-20", 700, 74);
   alerts("NZDCAD", "label-21", "arrow-21", "ttp-21", "tp-21", "act-21", 700, 92);
   alerts("CHFCAD", "label-22", "arrow-22", "ttp-22", "tp-22", "act-22", 700, 110);
   alerts("GBPCAD", "label-23", "arrow-23", "ttp-23", "tp-23", "act-23", 700, 128);
   return (0);
}

void alerts(string a_symbol_0, string a_name_8, string a_name_16, string a_name_24, string a_name_32, string a_name_40, int a_x_48, int a_y_52) {
   string ls_unused_176;
   double l_ima_184;
   double l_ima_192;
   double l_ima_200;
   double l_ima_208;
   color l_color_220;
   string l_text_224;
   color l_color_232;
   string l_text_236;
   color l_color_244;
   string l_text_248;
   color l_color_256;
   string ls_unused_284;
   string ls_unused_292;
   string ls_unused_300;
   string ls_unused_308;
   int li_332;
   string ls_56 = "Daily Forex Signal";
   double l_point_64 = MarketInfo(a_symbol_0, MODE_POINT);
   int l_period_72 = 24;
   int l_period_76 = 72;
   double l_ima_80 = iMA(a_symbol_0, PERIOD_M30, l_period_72, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_88 = iMA(a_symbol_0, PERIOD_M30, l_period_76, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_96 = iMA(a_symbol_0, PERIOD_H1, l_period_72, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_104 = iMA(a_symbol_0, PERIOD_H1, l_period_76, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_112 = iMA(a_symbol_0, PERIOD_H4, l_period_72, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_120 = iMA(a_symbol_0, PERIOD_H4, l_period_76, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_128 = iMA(a_symbol_0, PERIOD_D1, l_period_72, 0, MODE_EMA, PRICE_CLOSE, 0);
   double l_ima_136 = iMA(a_symbol_0, PERIOD_D1, l_period_76, 0, MODE_EMA, PRICE_CLOSE, 0);
   int l_bool_144 = l_ima_80 > l_ima_88 && l_ima_96 > l_ima_104 && l_ima_112 > l_ima_120 && l_ima_128 > l_ima_136;
   int l_bool_148 = l_ima_80 < l_ima_88 && l_ima_96 < l_ima_104 && l_ima_112 < l_ima_120 && l_ima_128 < l_ima_136;
   int l_bool_152 = l_ima_80 > l_ima_88 && l_ima_96 > l_ima_104 && l_ima_112 > l_ima_120 && l_ima_128 < l_ima_136;
   int l_bool_156 = l_ima_80 < l_ima_88 && l_ima_96 < l_ima_104 && l_ima_112 < l_ima_120 && l_ima_128 > l_ima_136;
   int l_count_160 = 0;
   int li_164 = 49;
   int l_count_168 = 0;
   for (l_count_160 = 1; l_count_160 < li_164; l_count_160++) {
      l_ima_184 = iMA(a_symbol_0, PERIOD_M30, 24, 0, MODE_EMA, PRICE_CLOSE, l_count_160 - 1);
      l_ima_192 = iMA(a_symbol_0, PERIOD_M30, 72, 0, MODE_EMA, PRICE_CLOSE, l_count_160 - 1);
      l_ima_200 = iMA(a_symbol_0, PERIOD_M30, 24, 0, MODE_EMA, PRICE_CLOSE, l_count_160 + 1);
      l_ima_208 = iMA(a_symbol_0, PERIOD_M30, 72, 0, MODE_EMA, PRICE_CLOSE, l_count_160 + 1);
      if ((l_ima_184 > l_ima_192 && l_ima_200 < l_ima_208) || (l_ima_184 < l_ima_192 && l_ima_200 > l_ima_208)) l_count_168++;
   }
   int li_216 = l_count_168 < 1;
   double l_spread_316 = MarketInfo(a_symbol_0, MODE_SPREAD);
   string l_dbl2str_276 = DoubleToStr(l_spread_316, 0);
   double l_ask_324 = MarketInfo(a_symbol_0, MODE_ASK);
   if (l_ask_324 > 10.0) li_332 = 2;
   else li_332 = 4;
   double l_ihigh_336 = iHigh(a_symbol_0, PERIOD_D1, 1);
   double l_ilow_344 = iLow(a_symbol_0, PERIOD_D1, 1);
   double l_iclose_352 = iClose(a_symbol_0, PERIOD_D1, 1);
   double ld_360 = (l_ihigh_336 + l_ilow_344 + l_iclose_352) / 3.0;
   ld_360 = NormalizeDouble(ld_360, li_332);
   double ld_368 = 2.0 * ld_360 - l_ihigh_336;
   ld_368 = NormalizeDouble(ld_368, li_332);
   double ld_376 = 2.0 * ld_360 - l_ilow_344;
   ld_376 = NormalizeDouble(ld_376, li_332);
   double l_irsi_384 = iRSI(a_symbol_0, PERIOD_M30, 14, PRICE_CLOSE, 0);
   double l_imacd_392 = iMACD(a_symbol_0, PERIOD_M30, 5, 13, 1, PRICE_CLOSE, MODE_MAIN, 0);
   double l_imacd_400 = iMACD(a_symbol_0, PERIOD_M30, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
   double l_istochastic_408 = iStochastic(a_symbol_0, PERIOD_M30, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, 0);
   if (l_bool_144 && li_216 && l_irsi_384 > 50.0 && l_imacd_392 > 0.0 && l_imacd_400 > 0.0) {
      l_text_224 = "Buy";
      l_color_220 = Lime;
      l_color_256 = Lime;
      l_text_236 = l_ihigh_336;
      l_color_232 = Lime;
      l_text_248 = "TP";
      l_color_244 = Lime;
   } else {
      if (l_bool_148 && li_216 && l_irsi_384 < 50.0 && l_imacd_392 < 0.0 && l_imacd_400 < 0.0) {
         l_text_224 = "Sell";
         l_color_220 = Red;
         l_color_256 = Red;
         l_text_236 = l_ilow_344;
         l_color_232 = Red;
         l_text_248 = "TP";
         l_color_244 = Red;
      } else {
         if (l_bool_152 && li_216) {
            l_text_224 = "Buy";
            l_color_220 = Lime;
            l_color_256 = Lime;
            l_text_236 = ld_376;
            l_color_232 = Lime;
            l_text_248 = "TP";
            l_color_244 = Lime;
         } else {
            if (l_bool_156 && li_216) {
               l_text_224 = "Sell";
               l_color_220 = Red;
               l_color_256 = Red;
               l_text_236 = ld_368;
               l_color_232 = Red;
               l_text_248 = "TP";
               l_color_244 = Red;
            } else {
               l_text_224 = "";
               l_color_220 = Black;
               l_color_256 = Gray;
               l_text_236 = "";
               l_color_232 = Black;
               l_text_248 = "";
               l_color_244 = Black;
            }
         }
      }
   }
   ObjectCreate(a_name_16, OBJ_LABEL, WindowFind(ls_56), 0, 0);
   ObjectSetText(a_name_16, l_dbl2str_276, 7, "Arial Bold", Yellow);
   ObjectSet(a_name_16, OBJPROP_CORNER, 0);
   ObjectSet(a_name_16, OBJPROP_XDISTANCE, a_x_48);
   ObjectSet(a_name_16, OBJPROP_YDISTANCE, a_y_52 + 2);
   ObjectCreate(a_name_8, OBJ_LABEL, WindowFind(ls_56), 0, 0);
   ObjectSetText(a_name_8, a_symbol_0, 9, "Arial Bold", l_color_256);
   ObjectSet(a_name_8, OBJPROP_CORNER, 0);
   ObjectSet(a_name_8, OBJPROP_XDISTANCE, a_x_48 + 13);
   ObjectSet(a_name_8, OBJPROP_YDISTANCE, a_y_52);
   ObjectCreate(a_name_40, OBJ_LABEL, WindowFind(ls_56), 0, 0);
   ObjectSetText(a_name_40, l_text_224, 10, "Arial Bold", l_color_220);
   ObjectSet(a_name_40, OBJPROP_CORNER, 0);
   ObjectSet(a_name_40, OBJPROP_XDISTANCE, a_x_48 + 65);
   ObjectSet(a_name_40, OBJPROP_YDISTANCE, a_y_52 + 0);
   ObjectCreate(a_name_32, OBJ_LABEL, WindowFind(ls_56), 0, 0);
   ObjectSetText(a_name_32, l_text_248, 10, "Arial Bold", l_color_244);
   ObjectSet(a_name_32, OBJPROP_CORNER, 0);
   ObjectSet(a_name_32, OBJPROP_XDISTANCE, a_x_48 + 98);
   ObjectSet(a_name_32, OBJPROP_YDISTANCE, a_y_52 + 0);
   ObjectCreate(a_name_24, OBJ_LABEL, WindowFind(ls_56), 0, 0);
   ObjectSetText(a_name_24, l_text_236, 10, "Arial Bold", l_color_232);
   ObjectSet(a_name_24, OBJPROP_CORNER, 0);
   ObjectSet(a_name_24, OBJPROP_XDISTANCE, a_x_48 + 120);
   ObjectSet(a_name_24, OBJPROP_YDISTANCE, a_y_52 + 0);
}

Comments