ParameterGetRange() - page 2 12 New comment fxsaber 2018.11.16 06:20 #11 From = OnTesterInit Start = 0 Step = 0 Stop = 0 Value = 5 Enable = false From = OnTesterPass Start = 1 Step = 2 Stop = 3 Value = 5 Enable = true From = OnTesterPass Start = 1 Step = 2 Stop = 3 Value = 5 Enable = true From = OnTesterDeinit Start = 1 Step = 2 Stop = 3 Value = 5 Enable = true Alain Verleyen 2018.11.16 08:20 #12 fxsaber: Obviously the parameters are only updated on the end of OnTesterInit(). What is the utility to use ParameterGetRange() AFTER you used ParameterSetRange() ? fxsaber 2018.11.16 09:17 #13 Alain Verleyen: Obviously the parameters are only updated on the end of OnTesterInit(). What is the utility to use ParameterGetRange() AFTER you used ParameterSetRange() ?#include <fxsaber\Expert.mqh> // https://www.mql5.com/ru/code/19003 #define TOSTRING(A) (" " + #A + " = " + (string)(A)) // Collects data on the range of input parameters for optimization string OptimizationData( void ) { string Str = NULL; MqlParam Params[]; string Names[]; if (EXPERT::Parameters(0, Params, Names)) { const int Size = ArraySize(Names); bool Enable; long Value, Start, Step, Stop; long Total = 1; Str = Params[0].string_value; for (int i = 0; i < Size; i++) if (ParameterGetRange(Names[i], Enable, Value, Start, Step, Stop)) { const long Interval = Stop - Start + 1; const long Amount = Enable ? Interval / Step + ((bool)(Interval % Step) ? 1 : 0) : 1; Str += "\n" + Names[i] + " = " + (string)Value + (Enable ? TOSTRING(Start) + TOSTRING(Step) + TOSTRING(Stop) + TOSTRING(Amount) : NULL); Total *= Amount; } Str += "\n" + TOSTRING(Total); } return(Str); } input int Range1 = 5; input int Range2 = 5; input int Range3 = 5; void OnTesterInit() { ParameterSetRange("Range1", true, 5, 1, 2, 3); Print(__FUNCTION__ + "\n" + OptimizationData()); } void OnTesterDeinit() { Print(__FUNCTION__ + "\n" + OptimizationData()); ChartClose(); } int OnInit() { return(INIT_FAILED); } OnTesterInit Experts\fxsaber\Test3.ex5 Range1 = 5 Start = 5 Step = 1 Stop = 50 Amount = 46 Range2 = 5 Start = 23 Step = 1 Stop = 78 Amount = 56 Range3 = 5 Start = 26 Step = 5 Stop = 83 Amount = 12 Total = 30912 OnTesterDeinit Experts\fxsaber\Test3.ex5 Range1 = 5 Start = 1 Step = 2 Stop = 3 Amount = 2 Range2 = 5 Start = 23 Step = 1 Stop = 78 Amount = 56 Range3 = 5 Start = 26 Step = 5 Stop = 83 Amount = 12 Total = 1344 12 New comment
Obviously the parameters are only updated on the end of OnTesterInit().
What is the utility to use ParameterGetRange() AFTER you used ParameterSetRange() ?
Obviously the parameters are only updated on the end of OnTesterInit().
What is the utility to use ParameterGetRange() AFTER you used ParameterSetRange() ?