Author: Copyright � 2008, EvgeTrofi

This script serves as an automated diagnostic tool designed to provide traders with a comprehensive snapshot of the specific trading conditions and limitations for any given financial instrument (such as a currency pair or commodity) on the MetaTrader platform. Instead of requiring a user to manually check several different menu screens, the script aggregates key technical data into a single, easy-to-read summary box.

Core Functionality

The logic follows a specific sequence to ensure the trader has accurate information before placing a trade:

1. Connection Verification Before performing any calculations, the script first checks if your platform is actively connected to the broker's server. If there is no connection, it interrupts the process and displays an error message, preventing the user from relying on outdated or non-existent data.

2. Market Parameter Retrieval The script pulls real-time data directly from the market provider for the current symbol being viewed. It gathers essential "rules" of the trade, including:

  • Spread: The difference between the buy and sell prices.
  • Stop Levels: The minimum distance required to place a stop-loss or take-profit order.
  • Tick Value: The monetary value gained or lost for every minor price movement (expressed in your account's base currency).

3. Swap and Overnight Costs The script identifies the specific type of "Swap" (overnight interest) applied to positions. It intelligently detects whether these costs are charged as a fixed amount, a percentage, or in your account currency, ensuring you understand the cost of holding a position overnight.

4. Trading Limits and Lot Sizes To help with risk management, the script calculates:

  • The minimum and maximum allowed lot sizes for the instrument.
  • The "Lot Step," which dictates the smallest increment you can trade.
  • Dynamic Margin Calculation: This is a key safety feature. The script looks at your available account balance (free margin) and calculates exactly how large of a position you can afford to open based on the broker's required margin. It ensures that you do not attempt to open a trade that exceeds 99% of your available funds, providing a small buffer for safety.

5. Risk Assessment The script performs a specific risk calculation: it determines the maximum volume (lot size) you can trade if you were to experience a loss of exactly 100 points. This helps traders quickly visualize their potential exposure based on their current balance.

6. Trading Permissions Finally, the script checks whether trading is currently enabled for that specific instrument and informs you of its status (allowed or disabled), which can be useful if certain assets are restricted during specific market hours.

User Experience

When executed, the script compiles all this data into a formatted text box. It provides a "quick glance" summary that allows a trader to verify costs, limits, and safety margins instantly, reducing the likelihood of manual errors when calculating trade sizes or managing risk.

Miscellaneous
It opens Message Boxes to the user
8 Views
0 Downloads
0 Favorites
Info
//+------------------------------------------------------------------+
//|                                                         Info.mq4 |
//|                                      Copyright © 2008, EvgeTrofi |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, EvgeTrofi"

#include <WinUser32.mqh>

int start()
{
 if (!IsConnected())
 {
  MessageBox("Ñâÿçü ñ ñåðâåðîì îòñóòñòâóåò èëè ïðåðâàíà\t","Âíèìàíèå!",MB_OK|MB_ICONERROR);
  return(-1);
 }
 string str2;
 string str="Íàèìåíîâàíèå\t\tÊîíñòàíòà\t\tÇíà÷åíèå\tÅä.èçì.\t\n\n";
 str=StringConcatenate(str,"Ñïðåä\t\t\tSPREAD\t\t\t",MarketInfo(Symbol(),MODE_SPREAD),"\t\tïóíêòîâ\t\n\n");
 str=StringConcatenate(str,"Ìèí. ñòîï\t\tSTOPLEVEL\t\t",MarketInfo(Symbol(),MODE_STOPLEVEL),"\t\tïóíêòîâ\t\n\n");
 str=StringConcatenate(str,"1 ëîò * 1 ïóíêò =\t\tTICKVALUE\t\t",MarketInfo(Symbol(),MODE_TICKVALUE),"\t\t",AccountCurrency(),"\t\n\n");
 switch(MarketInfo(Symbol(),MODE_SWAPTYPE))
 {
  case 0:
   str2="ïóíêòîâ";
   break;
  case 1:
   str2=Symbol();
   break;
  case 2:
   str2="%";
   break;
  case 3:
   str2=AccountCurrency();
   break;
 }
 str=StringConcatenate(str,"Ñâîï ïîêóïêè\t\tSWAPLONG\t\t",MarketInfo(Symbol(),MODE_SWAPLONG),"\t\t",str2,"\t\n\n");
 str=StringConcatenate(str,"Ñâîï ïðîäàæè\t\tSWAPSHORT\t\t",MarketInfo(Symbol(),MODE_SWAPSHORT),"\t\t",str2,"\t\n\n");
 str=StringConcatenate(str,"Ìèíèìàëüíûé ëîò\t\tMINLOT\t\t\t",MarketInfo(Symbol(),MODE_MINLOT),"\n\n");
 str=StringConcatenate(str,"Øàã ëîòà\t\tLOTSTEP\t\t\t",MarketInfo(Symbol(),MODE_LOTSTEP),"\n\n");
 double MaxLot = MarketInfo(Symbol(),MODE_MAXLOT);
 if(MaxLot>AccountFreeMargin()*0.99/MarketInfo(Symbol(),MODE_MARGINREQUIRED))//ãäå 0.99 - êîýôôèöèåíò çàïàñà
    MaxLot=AccountFreeMargin()*0.99/MarketInfo(Symbol(),MODE_MARGINREQUIRED);
 str=StringConcatenate(str,"Ìàêñèìàëüíûé ëîò = AccountFreeMargin() / MARGINREQUIRED = ",MaxLot,"\n\n");
 str=StringConcatenate(str,"Ëîò íà ïðîèãðûø 100 ïóíêòîâ = AccountFreeMargin() / 100 / TICKVALUE = ",AccountFreeMargin()/100/MarketInfo(Symbol(),MODE_TICKVALUE),"\n\n");
 
 if(MarketInfo(Symbol(),MODE_TRADEALLOWED)==0)
  str2="çàïðåùåíà";
 else
  str2="ðàçðåøåíà";
 str=StringConcatenate(str,"\nÒîðãîâëÿ ïî èíñòðóìåíòó ",Symbol()," ",str2,"\n\n");
 MessageBox(str,"Èíôîðìàöèÿ ïî èíñòðóìåíòó "+Symbol(),MB_OK|MB_ICONINFORMATION);
 
 return(0);
}

Comments