analysis tool

 

Hello everyone!

Sorry for my English.
I need help, I am making a tool to draw specific areas, in principle the tool works fine but there are two functions that when executed block the MT4 and I have to close it, these two functions are the ones that perform the "RESET" button and the button “DEL”, the first its function should delete all the analysis carried out by this tool and redraw the initial basic elements (vertical lines and start zone in their initial position = at the start of the indicator) the other “DEL” would only delete the elements graphics that are created by pressing the "Create processes" button, leaving the vertical lines and the start zone in the current position and not in the start position. This gauge has the option to be repositioned to the bottom left or right by pressing the “L” or “R” buttons.
                          Could someone inform me or tell me that part of the code of the two "RESET" buttons and the "DEL" button is wrong or something is missing.
Thank you very much.

 
Manuel De Los Heros Soler:

Hello everyone!

Sorry for my English.
I need help, I am making a tool to draw specific areas, in principle the tool works fine but there are two functions that when executed block the MT4 and I have to close it, these two functions are the ones that perform the "RESET" button and the button “DEL”, the first its function should delete all the analysis carried out by this tool and redraw the initial basic elements (vertical lines and start zone in their initial position = at the start of the indicator) the other “DEL” would only delete the elements graphics that are created by pressing the "Create processes" button, leaving the vertical lines and the start zone in the current position and not in the start position. This gauge has the option to be repositioned to the bottom left or right by pressing the “L” or “R” buttons.
                          Could someone inform me or tell me that part of the code of the two "RESET" buttons and the "DEL" button is wrong or something is missing.
Thank you very much.

Hello 

First get the warnings the compiler gives out of the way .

For instance in the ReDraw function (but not only there) you have a block that says 

double price1 = ....
double price2 = ....

But you also maintain these values in the global scope . So it is not clear if you are doing a temporary calculation locally or wanting to change the "global" value.

Then you also have the object names , when you send an object creation you ask the compiler to find and object and create it if it does not exist but the variable you are sending

the object name (to the function) is a "global" container of an object .

Also i did not understand the need for the Timer loop , although that is not the problem.(and if it is for "looking smooth" you can go up to 44ms as that is close to the human eye "refresh rate")

You also could have a switch for when the system is busy , and don't allow redraws when when the system is busy . (set the system as busy on chart event when a button is clicked and a process starts and then cancel it at the end) although that is not the issue either.

Can't go deeper than that as the issues with the warnings do not allow for further mods because i do not know how you want to use variables in these functions .

Cheers :)

PS : If your goal is to allow the user to draw alert zones there are more fun ways to do it , not easier , but more fun 

 
Lorentzos Roussos #:

Hello 

First get the warnings the compiler gives out of the way .

For instance in the ReDraw function (but not only there) you have a block that says 

But you also maintain these values in the global scope . So it is not clear if you are doing a temporary calculation locally or wanting to change the "global" value.

Then you also have the object names , when you send an object creation you ask the compiler to find and object and create it if it does not exist but the variable you are sending

the object name (to the function) is a "global" container of an object .

Also i did not understand the need for the Timer loop , although that is not the problem.(and if it is for "looking smooth" you can go up to 44ms as that is close to the human eye "refresh rate")

You also could have a switch for when the system is busy , and don't allow redraws when when the system is busy . (set the system as busy on chart event when a button is clicked and a process starts and then cancel it at the end) although that is not the issue either.

Can't go deeper than that as the issues with the warnings do not allow for further mods because i do not know how you want to use variables in these functions .

Cheers :)

PS : If your goal is to allow the user to draw alert zones there are more fun ways to do it , not easier , but more fun 

Hello Lorentzos!

Thank you very much for the help. I will tell you: The idea of this Indicator or Analysis Tool is to create an initial rectangle whose origin is in a vertical line as a reference that I later move to its real location and the height and position of the price I adapt to a specific candle later, the end of this rectangle is in the final line or "End Line". Once the rectangle is obtained and located, I select from the button panel how many replicas below and above I need and once selected, the central button "Crear procesos" is activated and it generates the replicas requested above and below. The intention of the "DEL" and "RESET" buttons is in "DEL" to delete these replicas but leaving where it is now (position and size modified and adapted to a specific wing) and "RESET" is to delete everything and create them. the reference lines and the initial rectangle to carry out a new analysis from the beginning. I have modified the code and now it works theoretically but I don't know if there is any error in it; You ask about the "price1 and price2" as global and then changed later, I did it like this since I couldn't find a way for the replicas to work well, maybe you can help me to optimize it.
All the best
By the way, I am very envious of you. I was in Milos and I fell in love with that island and its friendly people.

 
Manuel De Los Heros Soler #:

Hello Lorentzos!

Thank you very much for the help. I will tell you: The idea of this Indicator or Analysis Tool is to create an initial rectangle whose origin is in a vertical line as a reference that I later move to its real location and the height and position of the price I adapt to a specific candle later, the end of this rectangle is in the final line or "End Line". Once the rectangle is obtained and located, I select from the button panel how many replicas below and above I need and once selected, the central button "Crear procesos" is activated and it generates the replicas requested above and below. The intention of the "DEL" and "RESET" buttons is in "DEL" to delete these replicas but leaving where it is now (position and size modified and adapted to a specific wing) and "RESET" is to delete everything and create them. the reference lines and the initial rectangle to carry out a new analysis from the beginning. I have modified the code and now it works theoretically but I don't know if there is any error in it; You ask about the "price1 and price2" as global and then changed later, I did it like this since I couldn't find a way for the replicas to work well, maybe you can help me to optimize it.
All the best
By the way, I am very envious of you. I was in Milos and I fell in love with that island and its friendly people.

I see . So the idea is to create zones around the zone the user defines . 

The suggestion would be to clear the warnings of the editor , other than that nice work .  👍

Yeah it's hard to stay healthy in Greece with all the gyros,the spanakopita,the pastichio, the beautiful women .

Try Andros and Syros next time although venturing to the smaller islands has its own magic .  😇

 
Lorentzos Roussos # :

I'm already seeing So the idea is to create zones around the user defined zone.

The suggestion would be to delete the editor's warnings, other than that, good job. 👍

Yes, it is hard to keep healthy in Greece with all the gyros, the spanakopita, the pastichio, the beautiful women.

Try Andros and Syros next time, although venturing to the smaller islands has its own magic. 😇

Look at the snow!

I'm trying to optimize the indicator and replace the "2,3,4,5,6,7 and 8" buttons with just one where I can put the number + enter, my problem is that I can't find information in MQL4 about how You should make the window, box or button to be able to do this, you would be very kind if you can help me how to do it, with you I write a small code for a single data input button and another that when pressed makes me a comment with the number or text of the button data input, I will be able to understand it and apply it to my Indicator.

Ευχαριστώ πολύ

Come on! The Andros and Syros thing my wife and I already had in mind, thank you very much because there are so many islands that we would not know where to start and do not want to go to macro tourist islands, such as Santorini, Nikonos, etc. Well, we believe there should be smaller, prettier and quieter islands.

 
Manuel De Los Heros Soler #:

Of course here is a sample .

#property strict

string system_tag="TEST_";
int inputValue=0;
int OnInit()
  {
  //first delete all this systems objects 
  ObjectsDeleteAll(ChartID(),system_tag);
  //Then we create a little edit box , where the user can enter their desired number of boxes
    ObjectCreate(ChartID(),system_tag+"_INPUT",OBJ_EDIT,0,0,0);//you can name it anything you want 
  //position and size it 
    ObjectSetInteger(ChartID(),system_tag+"_INPUT",OBJPROP_XSIZE,100);//pixels
    ObjectSetInteger(ChartID(),system_tag+"_INPUT",OBJPROP_YSIZE,20);//pixels
    ObjectSetInteger(ChartID(),system_tag+"_INPUT",OBJPROP_XDISTANCE,10);
    ObjectSetInteger(ChartID(),system_tag+"_INPUT",OBJPROP_YDISTANCE,30);
    //set the default text 
    ObjectSetString(ChartID(),system_tag+"_INPUT",OBJPROP_TEXT,"2");
    /*
    now whenever you call 
    string value=ObjectGetString(ChartID(),system_tag+"_INPUT",OBJPROP_TEXT);
    it will return whatever is in the edit box and place it inside the "value" string
    But , it will not work while the text is being edited 
    You can get the value when the user  finishes by the event id CHARTEVENT_OBJECT_ENDEDIT
    which tells you the user finished editing an object and which object it is.
    */
    //so to demonstrate this we have a variable in the global scope which holds our input 
    //let's display it
    ObjectSetString(ChartID(),system_tag+"_INPUT",OBJPROP_TEXT,IntegerToString(inputValue));
  
  return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  ObjectsDeleteAll(ChartID(),system_tag);
  }

void OnTick()
  {
  }

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
  //so if the id of the event is object having been edited 
  if(id==CHARTEVENT_OBJECT_ENDEDIT)
    {
    //and the object matches your input box 
      //sparam is string_parameter essentially it passes the name of the object that finished editing
      if(sparam==system_tag+"_INPUT"){
      //so if the object that finished editing has the same name with your input box
        //get the value 
          string value=ObjectGetString(ChartID(),system_tag+"_INPUT",OBJPROP_TEXT);
        //but this is in string mode you want an integer 
          int ivalue=(int)StringToInteger(value);
          //you can do it straight up of course
        /*
        Now you are in the advantageous position to know the previous value and the new one
        So if the value changed you can hit the user with a prompt message.
        */  
       //so if input changed
         if(ivalue!=inputValue){
          int response=MessageBox("Do this now ?","Prompt",MB_YESNOCANCEL);
          //and then you process the response 
          if(response==IDYES){//if they click yes
          //update your input value 
            inputValue=ivalue;
            Print("Doing something");
          }
          else if(response==IDNO){//if they click no which means retain the input but do nothing
            inputValue=ivalue;
            //doing nothing
          }
          else{//if they click cancel revert to previous input 
            //nothing actually 
          }
        //and display the value - why? because they might have hit cancel!
          ObjectSetString(ChartID(),system_tag+"_INPUT",OBJPROP_TEXT,IntegerToString(inputValue));
        }
      //if input changed ends here
      /*
      of course you can do it with a button as well where when the button is clicked 
      you pull the value of the edit box and feed it to your function , so you would
      handle the click object event similarly as you do already with your other buttons
      
      */
      }
    }
  }
//+------------------------------------------------------------------+

I hope it helps .

If you want to get island ideas take a look at this guys channel :


Cheers 

 
Lorentzos Roussos # :

Por supuesto, aquí hay una muestra.

I hope it helps.

Si quieres obtener ideas de islas, echa un vistazo a este channel de chicos:


Salud

OKAY! Thank you very much. I'm going to study the code. And thanks a lot for the video ;-).

I'll let you know how it went.
The best

 
Manuel De Los Heros Soler #:

OKAY! Thank you very much. I'm going to study the code. And thanks a lot for the video ;-).

I'll let you know how it went.
The best

Great , you too 


 
Lorentzos Roussos # :

genial tu tambien


Very well.
Lorenzo!
I implemented and adapted your code and made a test with the data input box and the application box that creates a comment about what is entered, in principle it works fine, but once a result is received and when new data is created the result is perfect but in the data box the value remains offset, is it possible to fix it, i.e. center the data in the box after pressing "enter"?
How do you see the code? although 95% is yours.

The best

PDTA: What is better "ChartID()" or put "0"? And why does "(int) StringToInteger()" do that or why does it put (int)?





 
Manuel De Los Heros Soler #:

The translate function butchered your code there . 

If you mean text align i don't think you can align text of an edit box to the center.

 

@Manuel De Los Heros Soler — This is an English forum. Please respect the rules and post in English.

EDIT: Also, I highly recommend you use the coder styler in MetaEditor to improve your code presentation. Try to write your code more "beautifully". It makes for better reading and helps you find bugs more easily.

Reason: