Get user input for mql5 scripts

 

I created a working script, but when I load it to the chart I don't get Input Window like I get loading an EA, It loads automatically with its defaults.

What should I do with it? I remember, I started learning mql5, and back then it always asked for submission with an input window.

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2023.03.23
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
Fotikhbek Khusanov:

That is the natural behaviour of a script. Unlike an EA it is only executed once.

 
Miguel Angel Vico Alba #:

That is the natural behaviour of a script. Unlike an EA it is only executed once.

But What should I do if I want to Get user input? Its useless without input

 
Fotikhbek Khusanov #But What should I do if I want to Get user input? Its useless without input

You can add inputs to be customised before your single run.

Example of a script that modifies the TP/SL:

input double InpStoploss   = 0.0; //StopLoss Pips
input double InpTakeProfit = 0.0; //TakeProfit Pips

Simply put "input" to be displayed in the window before it is executed.

 
Fotikhbek Khusanov:

I created a working script, but when I load it to the chart I don't get Input Window like I get loading an EA, It loads automatically with its defaults.

What should I do with it? I remember, I started learning mql5, and back then it always asked for submission with an input window.

you can add this on top

#property script_show_inputs

in case you want the confirmation window add this :

#property script_show_confirm

https://www.mql5.com/en/docs/basis/preprosessor/compilation

Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
Documentation on MQL5: Language Basics / Preprocessor / Program Properties (#property)
  • www.mql5.com
Program Properties (#property) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Lorentzos Roussos #:

you can add this on top

#property script_show_inputs

Yes, important. Thank you!

 
Miguel Angel Vico Alba #:

Yes, important. Thank you!

You are welcome!

 
Lorentzos Roussos #:

you can add this on top

in case you want the confirmation window add this :

https://www.mql5.com/en/docs/basis/preprosessor/compilation

thank you)