Viewing the resource: Crafting a Market Dashboard Observatory with MQL5 đź”­

Crafting a Market Dashboard Observatory with MQL5 đź”­

Allan Munene Mutiiria 2025-06-21 14:49:20 95 Views
Join us for a detailed, professional, and engaging journey through our MQL5 code that automates fore...

Introduction

Greetings, forex astronomers! Picture the forex market as a vast cosmos, with prices twinkling like stars across symbols and timeframes. The Dashboard EA is your high-tech space observatory, an MQL5 bot that displays real-time bid prices for multiple currency pairs and trend indicators for various timeframes (M1, M5, H1, etc.), all with color-coded visuals to guide manual trading decisions. It doesn’t trade but equips you with a clear view of market movements, like a telescope scanning the galaxy. This article is your stargazer’s log, guiding you through the code with crystal-clear detail for beginners, a flow smoother than a meteor shower, and examples—like monitoring EURUSD trends—to keep you engaged. We’ll quote variables (e.g., "prices_PrevArray") and functions (e.g., "OnInit()") for clarity, balancing pro insights with a sprinkle of charm. Ready to scan the market stars? Let’s launch this observatory!

Strategy Blueprint

The Dashboard EA is a market monitoring interface:

  • Symbol Monitoring: Displays bid prices for all selected symbols (e.g., EURUSD, GBPUSD), with up/down arrows and color-coded names/prices (green/blue for bullish, red for bearish, gray for neutral) based on price changes.

  • Timeframe Analysis: Shows trend bars for timeframes (M1, M5, H1, H2, H4, D1, W1), colored green (bullish, close above open), red (bearish, close below open), or gray (neutral, close equals open).

  • Purpose: Provides real-time data to inform manual trades, not execute them, like a telescope guiding an astronomer’s observations.

  • Features: Highlights the current symbol and timeframe, with a compact, right-aligned layout for clarity. It’s like a space observatory, offering a panoramic view of the forex cosmos to guide trading decisions with precision. See below.

Code Implementation

Let’s navigate the MQL5 code like astronomers aligning a telescope, building our market dashboard step by step. We’ll flow from setting up the observatory to displaying symbol and timeframe data, updating visuals, and cleaning up, with transitions as seamless as a starry night. Each section includes code blocks, detailed explanations of what we’re doing, and examples to keep you engaged, all while staying beginner-friendly and professional.

Step 1: Setting Up the Space Observatory—Preparing the Dashboard

We start by assembling our observatory, defining the dashboard’s structure and core components.

//+------------------------------------------------------------------+
//|                                                 DASHBOARD EA.mq5 |
//|      Copyright 2025, ALLAN MUNENE MUTIIRIA. #@Forex Algo-Trader. |
//|                           https://youtube.com/@ForexAlgo-Trader? |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, ALLAN MUNENE MUTIIRIA. #@Forex Algo-Trader"
#property link      "https://youtube.com/@ForexAlgo-Trader?"
#property description "======= IMPORTANT =======\n"
#property description "1. This is a FREE EA."
#property description "2. To get the source code of the EA, follow the Copyright link."
#property description "3. In case of anything, contact developer via the link provided."
#property description "Hope you will enjoy the EA Logic.\n"
#property description "*** HAPPY TRADING! ***"
#property version   "1.00"

double prices_PrevArray[];

string Ask(string symbol){return DoubleToString(SymbolInfoDouble(symbol,SYMBOL_ASK),(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));}
string Bid(string symbol){return DoubleToString(SymbolInfoDouble(symbol,SYMBOL_BID),(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS));}

string truncPrds(ENUM_TIMEFRAMES period){
   string prd = StringSubstr(EnumToString(period),7);
   return prd;
}

ENUM_TIMEFRAMES periods[] = {PERIOD_M1,PERIOD_M5,PERIOD_H1,PERIOD_H2,PERIOD_H4,PERIOD_D1,PERIOD_W1};

int OnInit(){
   createText("1",truncPrds(_Period)+" "+Symbol()+" "+Bid(_Symbol),210,30,clrLime,13,"Arial Black");
   for (int i = 0; i < ArraySize(periods); i++){
      createText("Period "+IntegerToString(i),truncPrds(periods[i]),190+i*-25,55,clrWhite,10);
      createText("Bar "+IntegerToString(i),"-",190+i*-25,30,clrGray,40,"Arial Black");
   }
   createText("2",truncPrds(_Period)+" Price DashBoard",190,100,clrAqua,14);
   createText("3",_Symbol,190,120,clrGray,12);
   createText("4",Bid(_Symbol),110,120,clrGray,12);
   createText("5",CharToString(236),50,121,clrGray,12,"Wingdings");
   createText("6",CharToString(238),35,121,clrGray,12,"Wingdings");
   createText("7","EURUSDm",190,140,clrGray,12);
   createText("8",Bid("EURUSDm"),110,140,clrGray,12);
   createText("9",CharToString(236),50,141,clrGray,12,"Wingdings");
   createText("10",CharToString(238),35,141,clrGray,12,"Wingdings");
   for (int i=0; i < SymbolsTotal(true); i++){
      if (SymbolName(i,true)==_Symbol){
         createText("Symbol "+IntegerToString(i),"*"+SymbolName(i,true),190+7,160+i*20,clrGray,12);
      }
      else if (SymbolName(i,true)!=_Symbol){
         createText("Symbol "+IntegerToString(i),SymbolName(i,true),190,160+i*20,clrGray,12);
      }
      createText("Bid "+IntegerToString(i),Bid(SymbolName(i,true)),110,160+i*20,clrGray,12);
      createText("Arrow Up "+IntegerToString(i),CharToString(236),50,160+i*20,clrGray,12,"Wingdings");
      createText("Arrow Down "+IntegerToString(i),CharToString(238),35,160+i*20,clrGray,12,"Wingdings");
   }
   return(INIT_SUCCEEDED);
}
bool createText(string objName,string text,int x,int y, color clrTxt,
               int fontsize, string font = "Calibri"){
   ResetLastError();
   if (!ObjectCreate(0,objName,OBJ_LABEL,0,0,0)){
      Print(__FUNCTION__,": Failed to create the label: Error Code = ",GetLastError());
      return (false);
   }
   ObjectSetInteger(0,objName,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,objName,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,objName,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetString(0,objName,OBJPROP_TEXT,text);
   ObjectSetInteger(0,objName,OBJPROP_COLOR,clrTxt);
   ObjectSetInteger(0,objName,OBJPROP_FONTSIZE,fontsize);
   ObjectSetString(0,objName,OBJPROP_FONT,font);
   ChartRedraw(0);
   return (true);
}

We set up our observatory with a #property header, declaring the EA as a free offering by Allan in 2025 with a YouTube link, like calibrating our telescope’s lenses. We define "prices_PrevArray[]" to store previous bid prices, helper functions "Ask()", "Bid()", and "truncPrds()" to format prices and timeframes, and an array "periods[]" for timeframes (M1 to W1). In "OnInit()", we use "createText()" with "ObjectCreate(OBJ_LABEL)", "ObjectSetInteger()", "ObjectSetString()" to display: the current symbol and timeframe with bid price (e.g., “H1 EURUSD 1.2000”), timeframe labels (M1, M5, etc.) with trend bars, a “Price DashBoard” title, and a list of symbols (e.g., EURUSD, GBPUSD) with bids and arrows. The current symbol is starred (e.g., “*EURUSD”), aligned right-upper, like setting up telescope screens to scan the forex cosmos.

Step 2: Scanning the Cosmos—Tracking Timeframe Trends

We scan timeframe trends, coloring bars to indicate market direction, like observing star movements.

void OnTick(){
   for (int i=0; i<ArraySize(periods); i++){
      double
            open = iOpen(_Symbol,periods[i],0),
            close = iClose(_Symbol,periods[i],0);
      color clr = 0;
      if (close > open){clr = clrLime;}
      if (close < open){clr = clrRed;}
      if (close == open){clr = clrGray;}
      createText("Bar "+IntegerToString(i),"-",190+i*-25,30,clr,40,"Arial Black");
   }
}

In "OnTick()", we loop through "periods[]" using "ArraySize()", grabbing "iOpen()", "iClose()" for each timeframe’s latest bar. We compare open and close prices to set colors: lime for bullish ("close > open"), red for bearish ("close < open"), gray for neutral ("close == open"). We update trend bars with "createText()", like coloring an H1 bar red on EURUSD if the close is below the open, signaling a bearish trend for manual sell consideration.

Step 3: Charting the Stars—Monitoring Symbol Prices

We track bid prices across symbols, updating colors and arrows to show price direction, like charting celestial paths.

void OnTick(){
   // ... (timeframe trend logic)
   for (int i=0; i<SymbolsTotal(true); i++){
      ArrayResize(prices_PrevArray,SymbolsTotal(true));
      double bidPrice = SymbolInfoDouble(SymbolName(i,true),SYMBOL_BID);
      color clr_s = 0,clr_p=0,clr_a1=0,clr_a2=0;
      if (bidPrice > prices_PrevArray[i]){
         clr_s = clrLime; clr_p = clrBlue; clr_a1 = clrLime; clr_a2 = clrGray;
      }
      else if (bidPrice < prices_PrevArray[i]){
         clr_s = clrRed; clr_p = clrRed; clr_a1 = clrGray; clr_a2 = clrRed;
      }
      else if (bidPrice == prices_PrevArray[i]){
         clr_s = clrGray; clr_p = clrGray; clr_a1 = clrGray; clr_a2 = clrGray;
      }
      prices_PrevArray[i] = bidPrice;
      if (SymbolName(i,true)==_Symbol){
         createText("Symbol "+IntegerToString(i),"*"+SymbolName(i,true),190+7,160+i*20,clr_s,12);
      }
      else if (SymbolName(i,true)!=_Symbol){
         createText("Symbol "+IntegerToString(i),SymbolName(i,true),190,160+i*20,clr_s,12);
      }
      createText("Bid "+IntegerToString(i),Bid(SymbolName(i,true)),110,160+i*20,clr_p,12);
      createText("Arrow Up "+IntegerToString(i),CharToString(236),50,160+i*20,clr_a1,12,"Wingdings");
      createText("Arrow Down "+IntegerToString(i),CharToString(238),35,160+i*20,clr_a2,12,"Wingdings");
   }
}

We loop through symbols with "SymbolsTotal()", resizing "prices_PrevArray" with "ArrayResize()". For each symbol, we get the bid price via "SymbolInfoDouble()", "SymbolName()", comparing it to "prices_PrevArray[i]". If higher, we set lime for the symbol ("clr_s") and up arrow ("clr_a1"), blue for the price ("clr_p"), gray for the down arrow ("clr_a2"); if lower, red for symbol, price, and down arrow, gray for up arrow; if equal, all gray. We update "createText()" labels, like turning GBPUSD’s name green and price blue with a lime up arrow at 1.3500, indicating a bullish move for a potential buy.

Step 4: Shutting Down the Observatory—Cleaning Up

When observations are done, we tidy up to leave the chart clear.

void OnDeinit(const int reason){
}

In "OnDeinit()", we leave it empty, as no cleanup is coded, like leaving telescope screens active. We could add "ObjectsDeleteAll()" to clear labels (e.g., "Symbol 0", "Bid 0"), like shutting down the observatory, but for now, it’s a light cleanup, ready for the next scan. See below.

Why This EA’s an Observatory Legend (and Keeps You Engaged!)

This EA is a market monitoring legend, tracking symbol prices and timeframe trends like a telescope charting the forex cosmos. Its color-coded visuals make market moves instantly clear, guiding manual trades with precision. Example? Spot a red H1 bar and down arrow on EURUSD at 1.2000, signaling a sell opportunity, or a green M5 bar on GBPUSD for a buy—pure stargazing gold! Beginners can follow, and pros can enhance it, making it a must-have for manual traders seeking market insights.

Putting It All Together

To launch this EA:

  1. Open MetaEditor in MetaTrader 5 like powering up an observatory.

  2. Paste the code, compile (F5), and check for typos—no astronomer wants a misaligned telescope.

  3. Drop the EA on your chart and watch real-time symbol prices and timeframe trends.

  4. Use the dashboard to inform manual trades, like charting a course through the stars.

  5. Test on a demo first—real pips deserve a practice scan!

Conclusion

We’ve crafted a market dashboard observatory that tracks forex prices and trends with vivid, real-time visuals. This MQL5 code is our telescope, explained with detail to make you a market astronomer, a touch of charm to keep you engaged, and flow to carry you like a starry night. Ready to scan? Check our video guide on the website for a front-row seat to this cosmic mission. Now go chart those market stars! 🔭

Disclaimer: Trading’s like scanning the cosmos—thrilling but risky. Losses can exceed deposits. Test strategies on a demo account before going live.

Disclaimer: The ideas and strategies presented in this resource are solely those of the author and are intended for informational and educational purposes only. They do not constitute financial advice, and past performance is not indicative of future results. All materials, including but not limited to text, images, files, and any downloadable content, are protected by copyright and intellectual property laws and are the exclusive property of Forex Algo-Trader or its licensors. Reproduction, distribution, modification, or commercial use of these materials without prior written consent from Forex Algo-Trader is strictly prohibited and may result in legal action. Users are advised to exercise extreme caution, perform thorough independent research, and consult with qualified financial professionals before implementing any trading strategies or decisions based on this resource, as trading in financial markets involves significant risk of loss.

Recent Comments

Go to discussion to Comment or View other Comments

No comments yet. Be the first to comment!