量化交易系统

MT4-Display Text Information On Your Chart

  • 型号:
Main Image

Display all text information you need on your live charts.

First, import the library:

#import "osd.ex4"
void display(string osdText,ENUM_BASE_CORNER osdCorner,int osdFontSize,color osdFontColor, int osdAbs,int osdOrd);
// function to display
void undisplay(string osdText);
// function to undisplay
int splitText(string osdText,string &linesText[]);
// function called from display() and undisplay()
void delObsoleteLines(int nbLines);
// function called from display
string setLineName(int numLine);
// function called from display(), undisplay() and delObsoleteLines()
#import

Then, implement parameters:

  1. The info you want to display
  2. One of the four corners to display to
  3. Choose font size
  4. Choose font color
  5. Choose x distance
  6. Choose y distance
extern ENUM_BASE_CORNER corner=CORNER_RIGHT_LOWER; // corner to display to
extern int     fontSize=7; // size text
extern color   fontColor=clrWhite; // color text
extern int     abs = 10; // x distance from corner
extern int     ord = 15; // y distance from corner

The library is coded so that display() has default parameters except for the string osdText, so you can pass your string as the only parameter.

Then, construct your info in a string with multiple lines.

string servername=AccountServer();
   string companyname=AccountCompany();
   double _spread=MarketInfo(Symbol(),MODE_SPREAD);
   string msg=StringConcatenate("companyname : ",companyname,
                         "\n servername : ",servername,
                         "\n spread : ",_spread);

Finally, only two functions to use: display() and undisplay().

You can also switch on/off the info display if you add a bool parameter.

extern bool    displayOn=true; // switch on/off infos displaying
if(displayOn) // if displayOn is true, you display infos
     {
      display(msg,corner,fontSize,fontColor,abs,ord);
     }
   else // if displayOn is false, you do not display
     {
      undisplay(msg);
     }