Questions from Beginners MQL4 MT4 MetaTrader 4 - page 220

 
Hey! Guys, help me out! I can't think of a function. The Expert Advisor opens one position per day (between 00:00 and 23:59), i.e. one day, one order. The task is to find the series of continuous losses and display it in the log (using the command Print(), to print once). The number of elements in the series is entered from the keyboard (For example, if you entered 5 from the keyboard and the series has 4 losing days, then we ignore it --> wait for the occurrence of 5 or more days). A series is considered if losing days are consecutive or orders are closed in one day (they are opened once a day, and market orders can "hang" more than one day). For example, in the log there should be the following information: "The losing series on the following dates: 01.05, 02.05, 03.05, 04.05, 05.05". Important condition: recognize series (and consequently output it to the log), which is greater than or equal to the value entered from the keyboard (extern).
//
Personally I have the following idea:
1. Fiya fills the array of losing orders with their closing values ( Mass[i] = OrderCloseTime();). That is, the array stores only the closing dates and times of the losing orders
2. We start comparing the element at position i and at position i-1 (2 adjacent ones)
2.1 we compare them by converting the cell data to the day of the year ( TimeDayOfYear(Mass[i]) and TimeDayOfYear(Mass[i-1])
2.(Suppose the first losing day = 178, and the previous one = 176 --> no series, because they are not consecutive, respectively if the first = 178, and the second 177 --> we have a series)
2.3 With the for loop we look through all cells of the array and compare its neighbours. If there is a series of losses on neighboringelements of the array--> let's start accelerating until we reach the necessary minimumnumber of losing days to consider it as a series. 2. (if point 1 is fulfilled) BEFORE the series stops.
2.4 THE SERIES STOP --> remember the index of the array element where it ended and remember the number of elements in the series (the series can be == OR greater than the value entered from the keyboard)
3. ----here begins problem of realization---
3.1 We should "step back" somehow through series of losing days, knowing date of each element, translate date from datetime --> string,
3.11 fill string ( I don't know, maybe through StringAdd()?), and output it to LOG-file (not million times, just one)

Algorithm of Expert Advisor is not important, important is user's function itself

For Christ sake, help!))
Документация по MQL5: Основы языка / Переменные
Документация по MQL5: Основы языка / Переменные
  • www.mql5.com
Переменные должны быть объявлены перед их использованием. Для идентификации переменных используются уникальные имена. Описания переменных используются для их определения и объявления типов. Описание не является оператором. Индексом массива может быть только целое число. Допускаются не более чем четырехмерные массивы. Нумерация элементов массива...
Files:
 
Hello. Signed up for the signal. But after a few days the percentage of total increase from a few hundred became only 58%. Percentages from previous months have lost their blue colour and turned grey. Why is this happening? What could be the reason?
Files:
 
Maestro8:
Hello. Signed up for the signal. But after a few days the percentage of total increase from a few hundred was only 58%. Percentages from previous months have lost their blue colour and turned grey. Why is this happening? What could be the reason?

You have signed up for yet another deposit divider. Do you see the vertical line on the chart to the left of the 76th trade? This line shows the moment you connected to the monitoring. Before the connection to monitoring, this account was "withdrawn" from several dozens of other accounts that do not have such a pretty picture (they were safely drained). The deposit with beautiful indicators is connected to the monitoring and receives money from newcomers who like beautiful pictures. So do not believe the indicators that were obtained before joining the monitoring.

 

A copy of an instance of the class.

If I make this assignment:

Cl1 = Cl2;

then when I subsequently change Cl1, then Cl2 changes as well.

So, obviously, the assignment is just a reference.

But I need to save an instance of a class which would store all the properties that were given to it at the time of the assignment.

How to do this?

 
Evgeny Potapov:

A copy of an instance of the class.

If I make this assignment:

then when I subsequently change Cl1, then Cl2 changes as well.

So, obviously, the assignment is just a reference.

But I need to keep an instance of a class which would store all the properties which were given to it at the time of assignment.

How to do this?

You probably do it:

CClass* cl1=new CClass;
CClass* cl2=cl1;

, and you need this.

CClass cl1;
CClass* _cl1=new CClass;
CClass cl2=cl1;
CClass _cl2=_cl1;
CClass* cl3=new CClass(cl1);
CClass* cl4=new CClass(_cl1);

You need a copy constructor:

class CClass{
public:
   CClass(){}
   CClass(CClass &mOther){this=mOther;}
};
 
Vladimir Simakov:

You need a copy builder:

Thank you!

I'll try it, but it's not clear how it works.

If it passes the copy reference to the copied class, what difference does it make?

Will both be referring to each other again?

 
Evgeny Potapov:

Thank you!

I'll give it a try, but it's not clear how it works.

If it passes the copy a reference to the copied class, what difference does it make?

Will both of them be referring to each other again?

No, they won't. This is a new object. And in the constructor you simply fill in the fields. There are subtleties there too, so chew on it) There's nothing about it in local help (although I may be wrong), so read how it's all done in C++ and make corrections for local realities. Good luck)

 
Vladimir Simakov:

They won't. This is a new object. And in constructor you just fill fields. There are subtleties there too, so chew on it) There is nothing about it in local help (although I may be wrong), so read how c++ does it all and make adjustments for local realities. Good luck)

Yes, that's how it works.

Thank you!

It would be interesting to know from the authors how it works:

{this=mOther;}

Why is there a transfer by value when one would expect a reference to be transferred?

Fortunately, such a copy construct is possible!

 

Good afternoon!

Can you please tell me why in my MT4 I can't set take and stop loss with my mouse from the entry point of the position?

Maybe I need to adjust something, but I don't understand what it is, please help me

 
from_Reva:

Good afternoon!

Can you please tell me why in my MT4 I can't set take and stop loss with my mouse from the entry point of the position?

Perhaps I need to configure something, but I do not understand what it is, please help me

Try holding down "Alt" on your keyboard and drag

Reason: