analysis tool - page 2

 


I have already corrected the code, from what I understand, it is not possible to center the data in the "EDIT" box, is that correct?

Thanks a lot.

//+------------------------------------------------------------------+
//|                                               Botones_prueba.mq4 |
//|                        Copyright 2022, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

string system_tag =  " 2";
int inputValue    =  0;
int ivalue, Input;

string Version = "Botones_prueba";
string Font    = "Bahnschrift SemiBold Condensed";
string Font2   = "Bahnschrift";
string Font3   = "Marlett";
string Font4   = "Webdings";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ObjectsDeleteAll(ChartID(),system_tag);

   CrearBoton("Analisis",1000, 2, 85, 16, clrBlack, clrPink, clrBlack,Font,11,"Analisis");
   CrearBoton("Close ZonasFunc", 1087, 2, 18, 16, clrBlack, clrWhite, clrBlack,Font2,11," X");
   EditCreate("ENTER",978, 2, 20, 16, clrBlack, clrLightGray, clrBlack,Font,11,system_tag);

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   ObjectsDeleteAll(0,system_tag);
   ObjectsDeleteAll(0,"Analisis");
   ObjectsDeleteAll(0,"Close ZonasFunc");
   ObjectsDeleteAll(0,"ENTER");
   Comment("");
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
//------------------------------------------------------
//+------------------------------------------------------------------+
//|  Inicio Función Crear procesos "Analisis"                        |
//+------------------------------------------------------------------+
  {
   if(id==CHARTEVENT_OBJECT_ENDEDIT)
     {
      if(sparam==system_tag+"_INPUT")
        {
         string value = ObjectGetString(ChartID(),system_tag+"_INPUT",OBJPROP_TEXT);
         value = (int)StringToInteger(value);
         if(ivalue != inputValue)
           {
            int response=MessageBox("¿Lo ejecutamos ahora? "," Pregunta",MB_YESNOCANCEL);
            if(response==IDYES)
              {
               inputValue = ivalue;
               Print("Ejecutando");
              }
            else
               if(response==IDNO)
                 {
                  inputValue = ivalue;
                 }
               else
                 {
                 }
            ObjectSetString(ChartID(),system_tag + "_INPUT",OBJPROP_TEXT,IntegerToString(inputValue)); 
           }
        }
     }
//+------------------------------------------------------------------+
//|  Inicio Función Botón "Analisis"                                 |
//+------------------------------------------------------------------+
   if(id == CHARTEVENT_OBJECT_CLICK && sparam == "Analisis")
     {
      Comment("");
      string value = ObjectGetString(ChartID(),system_tag + "_INPUT",OBJPROP_TEXT);      
      Comment(" Resultado = ",value);
     }
//+------------------------------------------------------------------+
//|  Inicio Función Botón "Close"                                    |
//+------------------------------------------------------------------+
   if(id == CHARTEVENT_OBJECT_CLICK && sparam == "Close ZonasFunc") //- Cerrar indicador.
     {
      ChartIndicatorDelete(0,0,Version);
     }
//+------------------------------------------------------------------+
  }
//===================================================================//
//+------------------------------------------------------------------+
//|  Creamos los botones                                             |
//+------------------------------------------------------------------+
void CrearBoton(string BotonName,int Xdistance, int Ydistance, int Xsize, int Ysize, color TextColor, color ObjBGColor, color ObjBorderColor, string ObjFont,
                int ButtonFontSize, string ObjText)
  {
//------------------------------------------------------
   if(ObjectFind(0,BotonName)==-1)
     {
      ObjectCreate(0,BotonName,OBJ_BUTTON,0,0,0);
      ObjectSetInteger(0,BotonName,OBJPROP_XDISTANCE,Xdistance);
      ObjectSetInteger(0,BotonName,OBJPROP_YDISTANCE,Ydistance);
      ObjectSetInteger(0,BotonName,OBJPROP_XSIZE,Xsize);
      ObjectSetInteger(0,BotonName,OBJPROP_YSIZE,Ysize);
      ObjectSetInteger(0,BotonName,OBJPROP_COLOR,TextColor);
      ObjectSetInteger(0,BotonName,OBJPROP_BGCOLOR,ObjBGColor);
      ObjectSetInteger(0,BotonName,OBJPROP_BORDER_COLOR,ObjBorderColor);
      ObjectSetString(0,BotonName,OBJPROP_FONT,ObjFont);
      ObjectSetInteger(0,BotonName,OBJPROP_FONTSIZE,ButtonFontSize);
      ObjectSetString(0,BotonName,OBJPROP_TEXT,ObjText);
     }
//------------------------------------------------------
  }
//===================================================================//
//+------------------------------------------------------------------+
//|  Creamos casilla entrada de datos                                |
//+------------------------------------------------------------------+
void EditCreate(string BotonName,int Xdistance, int Ydistance, int Xsize, int Ysize, color TextColor, color ObjBGColor, color ObjBorderColor, string ObjFont,
                int ButtonFontSize, string ObjText)
  {
   if(ObjectFind(0,system_tag +"_INPUT")==-1)
     {
      ObjectCreate(0,system_tag+"_INPUT",OBJ_EDIT,0,0,0);
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_XDISTANCE,Xdistance); //pixels
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_YDISTANCE,Ydistance); //pixels
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_XSIZE,Xsize);         //pixels
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_YSIZE,Ysize);         //pixels
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_COLOR,TextColor);
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_BGCOLOR,ObjBGColor);
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_BORDER_COLOR,ObjBorderColor);
      ObjectSetString(0,system_tag+"_INPUT",OBJPROP_FONT,ObjFont);
      ObjectSetInteger(0,system_tag+"_INPUT",OBJPROP_FONTSIZE,ButtonFontSize);
      ObjectSetString(0,system_tag+"_INPUT",OBJPROP_TEXT,ObjText);
     }
  }
//===================================================================//}
//+------------------------------------------------------------------+


and Happy Holidays




 
Manuel De Los Heros Soler #:


I have already corrected the code, from what I understand, it is not possible to center the data in the "EDIT" box, is that correct?

Thanks a lot.


and Happy Holidays




No unfortunately it cannot be centered . 

Happy holidays too

 
Manuel De Los Heros Soler #:

I have already corrected the code, from what I understand, it is not possible to center the data in the "EDIT" box, is that correct?

Yes, it is possible

string Prefix="Test Object:";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
  int width=200, height=70,x_distance=100+width, y_distance=30;
  string obname=Prefix+"Rectangle Label";
  RectangleLabelCreate(obname,x_distance+10,y_distance-10,width+20,(height+10)*3+10,clrLime);
  for(int x=1; x<4; x++)
   {
    obname=Prefix+"Edit "+(string)x;
    EditCreate(obname,"EDIT",x_distance,y_distance,width,height,false,12);
    if(x==2)
      ObjectSetInteger(0,obname,OBJPROP_ALIGN,ALIGN_LEFT);
    if(x==3)
      ObjectSetInteger(0,obname,OBJPROP_ALIGN,ALIGN_RIGHT);
    y_distance+=height+10;
   }
//---
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  ObjectsDeleteAll(0,Prefix);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
//---

//--- return value of prev_calculated for next call
  return(rates_total);
}
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
  if(id==CHARTEVENT_OBJECT_CLICK)
   {
    Print(sparam," Clicked");
    if(sparam==Prefix+"Edit 1")
     {

     }

   }
  if(id==CHARTEVENT_CLICK)
   {
    Print("Chart Clicked at x ",lparam,", y ",dparam);
   }

  if(id==CHARTEVENT_KEYDOWN)
   {
    Print("Key Pressed. Code ",lparam,"  Status ",sparam);
   }
//---
}
//+------------------------------------------------------------------+
void EditCreate(string obname,string obtext,int x_dist,int y_dist,int xsize,int ysize,bool readonly,int font_size)
{

  ObjectCreate(0,obname,OBJ_EDIT,0,0,0);
  ObjectSetInteger(0,obname,OBJPROP_XDISTANCE,x_dist);
  ObjectSetInteger(0,obname,OBJPROP_YDISTANCE,y_dist);
  ObjectSetInteger(0,obname,OBJPROP_XSIZE,xsize);
  ObjectSetInteger(0,obname,OBJPROP_YSIZE,ysize);
  ObjectSetInteger(0,obname,OBJPROP_BGCOLOR,clrAntiqueWhite);
  ObjectSetInteger(0,obname,OBJPROP_BORDER_COLOR,clrBlack);
  ObjectSetInteger(0,obname,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
  ObjectSetInteger(0,obname,OBJPROP_BACK,false);
  ObjectSetInteger(0,obname,OBJPROP_SELECTED,false);
  ObjectSetInteger(0,obname,OBJPROP_COLOR,clrBlack);
  ObjectSetInteger(0,obname,OBJPROP_READONLY,readonly);
  ObjectSetString(0,obname,OBJPROP_FONT,"arial");
  ObjectSetString(0,obname,OBJPROP_TEXT,obtext);
  ObjectSetInteger(0,obname,OBJPROP_FONTSIZE,font_size);
  ObjectSetInteger(0,obname,OBJPROP_ALIGN,ALIGN_CENTER);
}
//+------------------------------------------------------------------+
void RectangleLabelCreate(string obname,int x_dist,int y_dist,int xsize,int ysize,color BGC,color mCol=clrSilver,int bw=3)
{
  ObjectCreate(0,obname,OBJ_RECTANGLE_LABEL,0,0,0);
  ObjectSetInteger(0,obname,OBJPROP_XDISTANCE,x_dist);
  ObjectSetInteger(0,obname,OBJPROP_YDISTANCE,y_dist);
  ObjectSetInteger(0,obname,OBJPROP_XSIZE,xsize);
  ObjectSetInteger(0,obname,OBJPROP_YSIZE,ysize);
  ObjectSetInteger(0,obname,OBJPROP_BGCOLOR,BGC);
  ObjectSetInteger(0,obname,OBJPROP_COLOR,mCol);
  ObjectSetInteger(0,obname,OBJPROP_BORDER_TYPE,BORDER_FLAT);
  ObjectSetInteger(0,obname,OBJPROP_WIDTH,bw);
  ObjectSetInteger(0,obname,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
  ObjectSetInteger(0,obname,OBJPROP_BACK,false);
  ObjectSetInteger(0,obname,OBJPROP_SELECTABLE,false);
  ObjectSetInteger(0,obname,OBJPROP_SELECTED,false);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 
Keith Watford #:

Yes, it is possible

They fixed it ? Awesome , thank you Keith 

I assume we can align text right or left in buttons now too 
 
Keith Watford #:

Yes, it is possible

Thank you very much Keith.
 
Thank you very much to all.