int nquotes_setup(string className, string assemblyName);
className - fully qualified .NET class name assemblyName - .NET assembly file name (without extension)
Zero in case of success. Negative error code in case of failure.
This function must be called once as the first step in the program init() special function. It is used to associate the current MQL program with a .NET class. If you pass NULL values the whole "ExpertsDirPath" directory will be scanned searching for the class. If there are several expert advisor classes found - the dialog will be presented for the manual selection.
// load a .NET class "MovingAverageEA" of "MyCompany" namespace // from "MyCompanyEA.dll" file located in the "ExpertsDirPath" directory nquotes_setup("MyCompany.MovingAverageEA", "MyCompanyEA");
NQuotes event handling functions correspond to the MQL event handling functions.
int nquotes_init();
Negative error code in case of failure, otherwise the return value of the .NET class init() method.
This function must be called once from the MQL program init() special function. It initiates a call to the .NET class init() method and waits until that method returns before proceeding. An alternative name for init() is OnInit().
int nquotes_start();
Negative error code in case of failure, otherwise the return value of the .NET class start() method.
This function must be called once from the MQL program start() special function. It initiates a call to the .NET class start() method and waits until that method returns before proceeding. An alternative name for start() is OnTick() for expert advisors and OnStart() for MQL scripts.
int nquotes_deinit();
Negative error code in case of failure, otherwise the return value of the .NET class deinit() method.
This function must be called once from the MQL program deinit() special function. It initiates a call to the .NET class deinit() method and waits until that method returns before proceeding. An alternative name for deinit() is OnDeinit().
double nquotes_on_tester();
Negative error code in case of failure, otherwise the return value of the .NET class OnTester() method.
This function must be called once from the MQL program OnTester() special function. It initiates a call to the .NET class OnTester() method and waits until that method returns before proceeding.
int nquotes_on_timer();
Negative error code in case of failure.
This function must be called once from the MQL program OnTimer() special function. It initiates a call to the .NET class OnTimer() method and waits until that method returns before proceeding.
int nquotes_on_chart_event(int id, long lparam, double dparam, string sparam);
Negative error code in case of failure.
This function must be called once from the MQL program OnChartEvent() special function. It initiates a call to the .NET class OnChartEvent() method and waits until that method returns before proceeding.
Property functions search for a public property or a field with the given name on the .NET class that was associated using a call to nquotes_setup() function.
Setter functions return zero in case of success, and a negative error code in case of failure.
Getter functions return the propety value in case of success, and some default value in case of failure.
bool nquotes_get_property_bool(string name); int nquotes_set_property_bool(string name, bool value); char nquotes_get_property_sbyte(string name); int nquotes_set_property_sbyte(string name, char value); uchar nquotes_get_property_byte(string name); int nquotes_set_property_byte(string name, uchar value); short nquotes_get_property_short(string name); int nquotes_set_property_short(string name, short value); ushort nquotes_get_property_ushort(string name); int nquotes_set_property_ushort(string name, ushort value); int nquotes_get_property_int(string name); int nquotes_set_property_int(string name, int value); uint nquotes_get_property_uint(string name); int nquotes_set_property_uint(string name, uint value); long nquotes_get_property_long(string name); int nquotes_set_property_long(string name, long value); ulong nquotes_get_property_ulong(string name); int nquotes_set_property_ulong(string name, ulong value); float nquotes_get_property_float(string name); int nquotes_set_property_float(string name, float value); double nquotes_get_property_double(string name); int nquotes_set_property_double(string name, double value); datetime nquotes_get_property_datetime(string name); int nquotes_set_property_datetime(string name, datetime value); color nquotes_get_property_color(string name); int nquotes_set_property_color(string name, color value); string nquotes_get_property_string(string name); int nquotes_set_property_string(string name, string value); int nquotes_get_property_array_size(string name); int nquotes_get_property_adouble(string name, double& value[]); int nquotes_set_property_adouble(string name, double& value[], int count=WHOLE_ARRAY, int start=0);
function | MQL value type | .NET property type | notes |
---|---|---|---|
nquotes_get_property_bool | bool | bool | |
nquotes_get_property_sbyte | char | sbyte | |
nquotes_get_property_byte | uchar | byte | |
nquotes_get_property_short | short | short | |
nquotes_get_property_ushort | ushort | ushort | |
nquotes_get_property_int | int | int | |
nquotes_get_property_uint | uint | uint | |
nquotes_get_property_long | long | long | |
nquotes_get_property_ulong | ulong | ulong | |
nquotes_get_property_float | float | float | |
nquotes_get_property_double | double | double | |
nquotes_get_property_datetime | datetime | System.DateTime | It is converted to MQL using the "NQuotes.MqlDateTime" class. |
nquotes_get_property_color | color | System.Drawing.Color | It is converted to MQL using the "System.Drawing.ColorTranslator" class. |
nquotes_get_property_string | string | string | |
nquotes_get_property_adouble | double arr[] | double[] | The MQL array variable must be preallocated with enough space. Use nquotes_get_property_array_size() to get the right size. |
int nquotes_get_property_array_size(string name);
Array length of a property, that must be a one-dimensional array. Negative error code in case of failure.
int nquotes_get_property_adouble(string name, double& value[]);
The number of copied array elements in case of success. Negative error code in case of failure.
Fills the provided array with the values copied from the property of type "double[]". The array must be big enough to hold the property data.
// in C# the property can be declared like this : // public double[] SongDurations { // get { return new double[] { 3.52, 4.39, 0.46, 1.38 }; } // } // MQL code int songsCount = nquotes_get_property_array_size("SongDurations"); double songDurations[]; ArrayResize(songDurations, songsCount); nquotes_get_property_adouble("SongDurations", songDurations); Print("the first song duration is ", songDurations[0]); // prints "3.52"
int nquotes_set_property_adouble(string name, double& value[],
int count=WHOLE_ARRAY, int start=0);
Negative error code in case of failure.
Setting a property of type "double[]".