Download MetaTrader 5
To add comments, please log in or register
Write your articles using our editor. It is convenient!
Pablo Estonia
17
Pablo Estonia 2011.02.17 19:02 

Hello everyone,

I just started coding MQL some weeks ago and there's a lot of work to be done to get an fine EA.

Until now, there're a lot of questions I need some help on. Perhaps I can get some skill of yours ;-)

1. I'm trying to create a simple label, displayed in the chart window. I tried to use some code fragments from the board and the reference, but it doesn't work. 

ObjectCreate("ObjName", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("ObjName","your Text",7, "Verdana", Red);
   ObjectSet("ObjName", OBJPROP_CORNER, 0);
   ObjectSet("ObjName", OBJPROP_XDISTANCE, 20);
   ObjectSet("ObjName", OBJPROP_YDISTANCE, 20);

 The string "ObjectSet" is not accepted/ known by the MT Editor? It's just displayed as simple code in black.

 2. I want to create a simple order to get first knowledge for this. How can I create a simple order without any special functions? Perhaps like: Order one new position at new tick, value 2.3456, used volume= 1000 EUR. 

 I hope I can look forward to your greatful help ;-) Thanks! 

Pablo Estonia
17
Pablo Estonia 2011.02.17 19:57  

Hello again,

I actually solved the 2nd question by my own. ;-)

Slawa
Moderator
6743
Slawa 2011.02.18 10:41  

https://www.mql5.com/en/docs (btw on the left bottom side of documentation page you can see links to spanish chm or pdf reference manual)

https://www.mql5.com/en/articles

https://www.mql5.com/en/code

for graphical objects creating and controlling see for example

https://www.mql5.com/en/code/70

https://www.mql5.com/en/code/218

https://www.mql5.com/en/code/215

https://www.mql5.com/en/code/222 

and so on. There are tons of materials

MQL5 Documentation
  • www.mql5.com
MetaQuotes Language 5 (MQL5) Reference - Documentation on MQL5.com
Rashid Umarov
Admin
11547
Rashid Umarov 2011.02.18 10:54  

Try this sample:

//+------------------------------------------------------------------+
//|                                                     OBJ_TEXT.mq5 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#define  UP          "\x0431"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   string label_name="my_OBJ_Label_object";
   if(ObjectFind(0,label_name)<0)
     {
      Print("Object ",label_name," not found. Error code = ",GetLastError());
      //--- create label object
      ObjectCreate(0,label_name,OBJ_LABEL,0,0,0);           
      //--- set X coordinate
      ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,200);
      //--- set Y coordinate
      ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,300);
      //--- set text color
      ObjectSetInteger(0,label_name,OBJPROP_COLOR,White);
      //--- set text of Label object
      ObjectSetString(0,label_name,OBJPROP_TEXT,UP);
      //--- set font name
      ObjectSetString(0,label_name,OBJPROP_FONT,"Wingdings");
      //--- set font size
      ObjectSetInteger(0,label_name,OBJPROP_FONTSIZE,10);
      //--- rotate the text 45 degrees clockwise
      ObjectSetDouble(0,label_name,OBJPROP_ANGLE,315);
      //--- disable object selection
      ObjectSetInteger(0,label_name,OBJPROP_SELECTABLE,false);
      //--- draw object on the chart
      ChartRedraw(0);                                      
     }
  }
//+------------------------------------------------------------------+

Pablo Estonia
17
Pablo Estonia 2011.02.20 23:12  
Thanks for your help, I'll try this immediately!
/
To add comments, please log in or register