Questions from Beginners MQL5 MT5 MetaTrader 5 - page 144

 
DC2008:

Read carefully:

Return value

The function returns the index of the found element, taking into account the array's seriality. If it fails, the function returns -1.

Therefore, it should be like this:

1. Correct me if I've misunderstood.

Found all minima in the interval:

double Low[];
CopyLow(_Symbol,_Period,tss,tspp,Low);

Since there is an array with minima, we use the ArrayMinimum function to find only the minimum from the array, without enumerating the gap in time(tss,tspp)

double min= Low[ArrayMinimum(Low)];  
Alert("min=",min);

2. In the script, I put the code into a function:

void OnDeinit(const int reason)

all time parameters are shown correctly, but the variable min=0.0, although when bidding was going on it was showing the minimum of the specified interval. What could be the problem?

 
forexman77:

1. Correct me if I have misunderstood.

We have found all minima in the interval:

Since there is an array with minima, we use the ArrayMinimum function to find only the minimum from the array, without enumerating the gap in time(tss,tspp)

2. In the script, the code is placed in the function:

all time parameters are shown correctly, but the variable min=0.0, although when bidding was going on it was showing the minimum of the specified interval. What could be the problem?

In the scope of the variable. Make it global.
Документация по MQL5: Основы языка / Переменные / Локальные переменные
Документация по MQL5: Основы языка / Переменные / Локальные переменные
  • www.mql5.com
Основы языка / Переменные / Локальные переменные - Документация по MQL5
 
zfs:
In the scope of the variable. Make it global.
Moved the variable "double min;" to global still =0.0.
 
forexman77:
Moved variable "double min;" to global still =0.0

Script:

void OnStart()
  {
   double Low[];
   CopyLow(_Symbol,_Period,0,10,Low);
   double min=Low[ArrayMinimum(Low)];
   Alert("min=",min);
  }
There is no OnInit and OnDeinit in the scripts.
 

You have an error in your documentation https://www.mql5.com/ru/docs/constants/chartconstants/charts_samples

int ChartFirstVisibleBar(constlong chart_ID=0)
{
//--- prepare a variable for getting the value of the property
long result=-1;
//--- reset the error value
ResetLastError();
//--- get the value of the property
if(!ChartGetInteger(chart_ID,CHART_WINDOW_YD ISTANCE,0,result)) it should be CHART_FIRST_VISIBLE_BAR
{
//--- print the error message to the "Experts" journal
Print(__FUNCTION__+", Error Code = ",GetLastError());
}
//--- return the value of the chart property
return((int)result);
}

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Примеры работы с графиком
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Примеры работы с графиком
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Примеры работы с графиком - Документация по MQL5
 
DC2008:

Script:

There is no OnInit and OnDeinit in the scripts.

Thank you so much!!!

It worked for me!!!

 

Please tell me which programs to use to protect the EA and to limit the time of work, for example I need to protect the EA from decompilation, so it works only for 5 days.

I need a program where I can permanently limit the run time of the EA to give the EA to other people for testing.

 

When testing an EA, I have encountered the following difficulty.

The Expert Advisor does not trade (it has to) if:

 if(Stop <=Start) { return;}

When testing, I set Stop parameters from 1 to 33, Start from 1 to 33.

Of course, the tester produces about 2/3 of null results because Stop > Start in the tester sometimes occurs during overshooting.

These null tests take a lot of time.

Question: How can we disable testing of null tests in the Expert Advisor's code?

Logically, the test time should be reduced after the ban?

 
forexman77:

When testing an EA, I have encountered the following difficulty.

The Expert Advisor does not trade (it has to) if:

When testing, I set Stop parameters from 1 to 33, Start from 1 to 33.

Of course, the tester produces about 2/3 of null results because Stop > Start in the tester sometimes occurs during overshooting.

These null tests take a lot of time.

The question is how to disable testing null tests in EA code.

https://www.mql5.com/ru/docs/common/expertremove

This works in the tester. // At least it worked in the build before last one. It's been a while since I checked it.

Документация по MQL5: Общие функции / ExpertRemove
Документация по MQL5: Общие функции / ExpertRemove
  • www.mql5.com
Общие функции / ExpertRemove - Документация по MQL5
 
MetaDriver:

https://www.mql5.com/ru/docs/common/expertremove

it works in the tester. // at least it worked in the build before last. it's been a while since i checked it.

I need a test pass. The EA does not trade if:

if(Stop <=Start) { return;}

I want to do this to reduce the testing time.

Maybe there is a function in the Strategy Tester specifically for the input parameters that the Expert Advisor has?

If we getStop <=Start, we skip this pass.