Input_Struct - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

This library reduces common operations when working with input parameters.
As a usage example, let's take a trading advisor. It is reasonable to use the OOP approach when writing trading logic, since it makes it easier to embed EAs into more complex systems.
Architecturally, a tester's OOP consultant looks like this.
Class System { People : Virtual blank check () {} //Input data is output in string form. virtual string to string( blank ) const = void ; //Input data is specified by string. dummy integer from string( constStringForce ) = void ; }; system * system = void ; blank initialize () { system = new system; } Blank check () { system. check (); } Blank solution initialization ( const integer ) { Delete system; }
The EA does not perform any operations. However, when it comes to not involving transaction logic but only input parameters, the code grows seriously, which reduces readability and increases the likelihood of errors. In fact, you need to perform unpleasant daily tasks.
Let's turn a little to the highlighted line in the code.
Trading practice shows that it is convenient to save/read input parameters in the form of strings, so that you can quickly and clearly see the input parameter group you are interested in (found).
amount = 1 , count = 2 , epochs = 3 , kov = 4.5 , log = 6.7 , flag = true amount = 2 , count = 3 , epochs = 4 , kov = 4.56 , log = 7.89 , flag = false
For example, in the text above there are two sets of input parameters.
Enter integer amount = 1 ; Enter integer count = 2 ; Enter integer period = 3 ; enter double incov = 4.56 ; enter double inlog = 7.89 ; input boolean flag = true ; struct input struct { Integer quantity; integer counting; integer period ; Double the Cov; Double the log; boolean flag; String to string ( blank ) constant { Stringstrength = void ; #define TOSTRING(A) Str += (:: String length (Str)? "," : invalid ) + #a + "=" + ( string )( this.a ); TOSTRING(amount); TOSTRING(count); toString( period ); TOSTRING(kov); TOSTRING(log); TOSTRING(flag); #undefTosterling return (Str); } // Writing has not started. integer from string( const string ) { return ( 0 ); } inInputs = {inAmount, inCount, inPeriod, inKoef, inLog, inFlag}; #includeBlank example: : check ( blank ) { // system code... // this.Inputs contains input parameters. }
The cumbersome code above is the same empty EA but only adds functionality to handle the input parameters (highlighted text). The code is unpleasant and doesn't even implement the important INPUT_STRUCT::FromString method.
If you want to add/remove an input parameter, you have to make corresponding changes in five places in this code. Every time!
#include//Structure of input parameters. INPUT_STRUCT in input; macroinput( integer , quantity, 1 ); macroinput( integer , count, 2 ); macroinput( integer , period , 3 ); macroinput( double ,kov, 4.56 ); macroinput( double , log, 7.89 ); macroinput( boolean , flag, true ); #includeBlank example: : check ( blank ) { // system code... // this.Inputs contains input parameters. }
Noticeably less text is highlighted. At the same time, all methods are implemented.

Note that using OOP methods it is possible to hide large amounts of repeated text in mqh files - as was done in the two examples above. OOP can also be concise.
The Expert Advisor processes pending orders Buy Stop and Sell Stop according to the time specified in its input parameters.
The simplest EA trading can analyze price changes on a given number of bars and open corresponding positions.
This indicator was written based on a forum request.
A simple indicator based on Bollinger Bands, showing its narrowing and widening phases in red/green.
Attachment download
📎 system.mqh (0.48 KB)
📎 example.mqh (0.46 KB)
📎 example_ontick.mqh (0.62 KB)
📎Input_Struct.mqh (43.33 KB)
📎 input_string_example_classic.mq5 (1.74 KB)
📎 Input_String_Example_Alternative.mq5 (1.41 KB)
Source: MQL5 #47932
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •