i try to convert my EA mql4 to mql5

 

Hi guys   how can convert  in mql5   this part  of  code ?


    ObjectCreate(0, "ViPrimario", OBJ_EDIT, 0, 2, 120);
    ObjectSetText(0, "ViPrimario", "P1", 10, "Arial", clrBlack);
    ObjectSetInteger(0, "ViPrimario", OBJPROP_CORNER, CORNER_LEFT_UPPER);
    ObjectSetInteger(0, "ViPrimario", OBJPROP_COLOR, clrWhite);
    ObjectSetInteger(0, "ViPrimario", OBJPROP_SELECTABLE, false);

ObjectSetText  not exist what i must use in alternative ?  thanks

 
faustf:
ObjectSetText

You may use ObjectSetString instead.

 

If you are too lazy to recode... copy and paste in your code.

void ObjectSetText(long chart_id, string obj_name, string text, int font_size, string font, color clr) {
   ObjectSetString(chart_id,obj_name,OBJPROP_TEXT,text);
   ObjectSetString(chart_id,obj_name,OBJPROP_FONT,font);
   ObjectSetInteger(chart_id,obj_name,OBJPROP_FONTSIZE,font_size);
   ObjectSetInteger(chart_id,obj_name,OBJPROP_COLOR,clr);
}
 

@Fabio Cavalloni thanks so much not exist a library  with this equivalent function?

and  example if i want  change this 

void OnTick()
{
    if(OnOffChiusuraAuto==1)
    {
        for (int ij = 0; ij < OrdersTotal(); ij++)
        {
            if( OrderSelect( ij, SELECT_BY_POS, MODE_TRADES ) == false )
            {
                Print("ERROR - Unable to select the order - ",GetLastError());
                break;
            } 
            

i notice orderselct in mql5  have only ticket  , is possible use  in this context ?  thanks

Fabio Cavalloni
Fabio Cavalloni
  • 2024.05.07
  • www.mql5.com
Trader's profile
 

I strongely suggest you to use CTrade class approach, read this article as a reference.

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

Trade Operations in MQL5 - It's Easy
Trade Operations in MQL5 - It's Easy
  • www.mql5.com
Almost all traders come to market to make money but some traders also enjoy the process itself. However, it is not only manual trading that can provide you with an exciting experience. Automated trading systems development can also be quite absorbing. Creating a trading robot can be as interesting as reading a good mystery novel.