How I make the EA with window's input as accessory?

 

Now I want to make an Script which can get "input" by window or other tools when it was executed.

For example, I have open 4 orders on USDJPY as below:

order 1:4259920  buy 4 lots

order 2: 4259921 buy 1 lots

order 3:4259922  buy  2 lots

order 4: 4259923 buy 2 lots

 Now I want to create an Script, named as "close_order", when I execute it, a window or other something can come out to receive two parameters(order ticket and n lots);then close this order ticket by n lots.

How I can get this window or similar tools.

 

In addition, shall I  create an EA which can use this Script-"close_order"which I just created in Script, just as use other functions,such as ordersend(),orderclose() and so on?

thanks a lot. 

 
vx0532:

Now I want to make an Script which can get "input" by window or other tools when it was executed.

For example, I have open 4 orders on USDJPY as below:

order 1:4259920  buy 4 lots

order 2: 4259921 buy 1 lots

order 3:4259922  buy  2 lots

order 4: 4259923 buy 2 lots

 Now I want to create an Script, named as "close_order", when I execute it, a window or other something can come out to receive two parameters(order ticket and n lots);then close this order ticket by n lots.

How I can get this window or similar tools.

 

In addition, shall I  create an EA which can use this Script-"close_order"which I just created in Script, just as use other functions,such as ordersend(),orderclose() and so on?

thanks a lot. 

Add in your script, property show input and then all the extern input

#property show_inputs
extern string My_Name ="my name";
extern int    My_Phone_Number = 12345678;
 
phi.nuts:

Add in your script, property show input and then all the extern input

 

Thank you for your kindly repley, but I can;t get my wanted purpose.

Now I want to clear of my questions as below:

1. I want to made an Scripts like this: when I execute it, at the very beginning, it will give me the chance to assign to some parameters used in the Script; after this, the Script will be executed with the updated parameters which were assigned just now completely. shall I achieve it?

2. When I make a Script--"scriptX", shall I make an EA which use this Script(scriptX)? if yes, how?

3. When I do like you said, add below code into my script.

#property show_inputs
extern string My_Name ="my name";
extern int    My_Phone_Number = 12345678;

 I just get these "inputs: My_Name="my name"; My_Phone_Number=12345678" at "experts"table and I don't know what is its sense or how to use it work well?

4. what is the difference between "extern string My_Name="my name"  " and " string My_Name="my name" " .

 
vx0532:

Thank you for your kindly repley, but I can;t get my wanted purpose.

Now I want to clear of my questions as below:

1. I want to made an Scripts like this: when I execute it, at the very beginning, it will give me the chance to assign to some parameters used in the Script; after this, the Script will be executed with the updated parameters which were assigned just now completely. shall I achieve it?

2. When I make a Script--"scriptX", shall I make an EA which use this Script(scriptX)? if yes, how?

3. When I do like you said, add below code into my script.

 I just get these "inputs: My_Name="my name"; My_Phone_Number=12345678" at "experts"table and I don't know what is its sense or how to use it work well?

4. what is the difference between "extern string My_Name="my name"  " and " string My_Name="my name" " .

 

1.  For the parameters you want to be able to change you need to make them type  extern  then they will show in the parameters/inputs box and you will be able to set them.

2.  A Script and EA are very similar the main difference is that a Script is normally designed to run one and then terminate,  an EA runs continuously with it's start() function being called on each tick.

3.  The code that phi.nuts  gave you is just an example. 

4.  See point 1. 

 
RaptorUK:

1.  For the parameters you want to be able to change you need to make them type  extern  then they will show in the parameters/inputs box and you will be able to set them.

 I am sorry for that I don't know where is "inputs/parameters box",  when they come out and how to set the parameters in them? 

2.  A Script and EA are very similar the main difference is that a Script is normally designed to run one and then terminate,  an EA runs continuously with it's start() function being called on each tick.

I mean whether I can create an EA which include the script / EA which is created by me just now? 

3.  The code that phi.nuts  gave you is just an example. 

4.  See point 1. 

Thank you for your comments. but I still don't know somethings as below:

1. Now I show a script code as below:

 

#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property show_inputs
extern string My_Name;

int start()
  {
  Print("my name is :",My_Name);
   return(0);
  } 

I want to use this script to print "my name is ABC" for the first time , "my name is XYZ" for the second time and other something for the next time; I mean "ABC" and "XYZ" should be assigned to My_Name by me when the script is executing rather than written into the codes in advance. How shall I? I need the very details, thanks.

2.  I mean whether I can create an EA which can execute the above script to print "My_Name" just like that the EA calls other functions, such as ordersend() and so on? I hope I have clear my meaning.

3.  Ok.

4. Point 1 is still pending. 

 

Thanks a lot! 

 
vx0532:

1. Now I show a script code as below:

 

I want to use this script to print "my name is ABC" for the first time , "my name is XYZ" for the second time and other something for the next time; I mean "ABC" and "XYZ" should be assigned to My_Name by me when the script is executing rather than written into the codes in advance. How shall I? I need the very details, thanks.

2.  I mean whether I can create an EA which can execute the above script to print "My_Name" just like that the EA calls other functions, such as ordersend() and so on? I hope I have clear my meaning.

3.  Ok.

1.  if you want multiple options then you have to have multiple extern string statements . . . 

extern string My_Name1 = "ABC";
extern string My_Name2 = "RST";
extern string My_Name3 = "XYZ";
extern string My_Name4 = "123";

 2.  The way I would do that is use the code in the script as a user defined function in your EA, to run the code that was in the sccript you just call the user defined function in the EA.

 
RaptorUK:

1.  if you want multiple options then you have to have multiple extern string statements . . . 

 2.  The way I would do that is use the code in the script as a user defined function in your EA, to run the code that was in the sccript you just call the user defined function in the EA.

 

Ok, my understanding about your replay as below:

1. we can never assign to or change paramenters once the script or EA which inclulde these parameters is executed. we just can change values by "extern"  for public variables in advance in the codes. yes?

2. we can't make EA or Script which can use or call other EA or script, but we can create some certain functions in EA or Script to use. yes? 

 
vx0532:

Ok, my understanding about your replay as below:

1. we can never assign to or change paramenters once the script or EA which inclulde these parameters is executed. we just can change values by "extern"  for public variables in advance in the codes. yes?

2. we can't make EA or Script which can use or call other EA or script, but we can create some certain functions in EA or Script to use. yes? 

1.  you can change the value held in any variable you like even extren variables,  but if you want the user to do that rather than the code the way you do that by using externs.

2.  there has been discussion about an EA running a script,  it is not possible just by using standard mql4 code and if you have the source code for the script why wouldn't you simply build that functionality into your EA ? 

 
RaptorUK:

1.  you can change the value held in any variable you like even extren variables,  but if you want the user to do that rather than the code the way you do that by using externs.

2.  there has been discussion about an EA running a script,  it is not possible just by using standard mql4 code and if you have the source code for the script why wouldn't you simply build that functionality into your EA ? 

Thank you very much for your patience.

1. yes, I want the user to change / assign to value of variable. but I still don't know how achieve this by using externs until now. you said:

extern string My_Name1 = "ABC";
extern string My_Name2 = "RST";
extern string My_Name3 = "XYZ";
extern string My_Name4 = "123";

but I think all the variables "My_Name1~4" have been assigned by code rather than user. so how user can assign to / change these variables?

2. Ok. you mean standard mql4 can't do this but source code can be copied to script / EA to do this. I think that is Ok. thanks.

3. In addition, accroding to my knowledge, "extern" means variables -- "My_Name1~4" are not in this file but "other places"; my question is that where / what are the "other places", other EA, Script, Indicator or all of them?

 

EA can set and use extern  variables , do not need use script.

use EA's extern  variables  directly.

 

 
vx0532: so how user can assign to / change these variables?
asked and answered
#property show_inputs