[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 489

 
DOCTORS:


I guess my brain functions have partially deteriorated after the holidays, which translates into a low level of self-reporting :(

The point is a little different:

1. As soon as the Expert Advisor starts, I assign the initial value of deposit to some variable (I am searching for function of assignment, although I can of course prescribe it manually in initial settings, but I have already been reproached for my poor programming skills, but I want to do it as a white person does).

2. Since my system is cunning, and works only one lot, the initial value of the lot (say) 1.0 ...

3. And the main question - I want after each profitable trade, the deposit was compared to the original, and if the new value (say) was more than 30%, I change the lot size value by 0.1, ie 1.0 +0.1, and so on constantly (clearly the nuance that constantly has to change the old value of the variable, and again the assignment operator of the variable value of the deposit).

Anyway, it goes like this.


In the library, see volume management tools by I. Kim and other versions, including the textbook version I gave you - when you understand how they work, it won't be hard to make your own, which is exactly what you need... That's how it is. Without it - no way - practice and solving typical problems - IMHO, first of all. See the trailer - capital management features by Igor Kim.
Files:
b-lots.mqh  3 kb
 
sss2019:

Is the file descriptor always greater than zero on successful opening?

Please see if the logic in this code, which opens the file for writing

wrong, and who would close a file after it's been created if there isn't one?

and then terminal will give you an open error in this case, so it's better to check file presence with flag FILE_CSV|FILE_READ, in this case if there is no file, terminal will be silent

 
FAQ:

wrong, and who will close the file after it is created if there is no file?

And then, the terminal will give you an open error in this case, so it's better to check for file with flag FILE_CSV|FILE_READ, in this case if there is no file, the terminal will be silent


Well it is there. If the file was open

  if(Handle >0)
  FileClose(Handle);

I made a record to the file, but the delimiter at the end is not added, and the tutorial says it's added automatically.

FileWrite(Handle,"Pair, Min, Max, Open, Close, Moment");
 

And if it wasn't there, you create it and don't close it. or then if you have an extra close (below in the code)

as for the delimiter - whatever delimiter you open the file with (instead of creating it), it will be the same

 


Hehe, it's a theme avatar. :)

2 Roman - thanks, we'll look into it.

 

FAQ:

And if it was not there, you create it and do not close it. or then if you have an extra close (below in the code)

the separator - whatever separator you open the file with (you don't create it), it will be the same


So why is it redundant I do not understand, if I do not close it immediately, then close it later. Please show me an example of how to open and close it correctly.

 
Please advise how to make Alert signal appear in the indicator, only once on the current bar. I tried to make a variable, and as long as this variable has value 0 the signal is allowed, as soon as the signal is sounded the variable takes value 1. But it doesn't work.
 
sss2019:
Please advise how to make Alert signal appear in the indicator, only once on the current bar. I tried to make a variable, and as long as this variable has value 0 the signal is allowed, as soon as the signal is sounded the variable takes value 1. But it doesn't work.

https://docs.mql4.com/ru/basis/variables/static
 
sss2019:
Please advise how to make Alert signal appear in the indicator, only once on the current bar. I tried to make a variable, and as long as this variable has value 0 the signal is allowed, as soon as the signal is sounded the variable takes value 1. But it doesn't work.
Files:
 
sss2019:
Please advise how to make an alert appear in an indicator, only once at the current bar. I tried to make a variable and as long as this variable has value 0 the signal is allowed. As soon as the signal has been emitted the variable takes value 1. But it doesn't work.


I usually make a variable LastBarAlert and write Time[0] to it when the alert is triggered.

And then elementary, Alert is displayed if LastBarAlert!=Time[0]

if (Signal && LastBarAlert!=Time[0]){
  Alert('Signal detected');
  LastBarAlert=Time[0];
}
Reason: