[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 4

 

Not smiling

 
Fox_RM: In subsequent iterations everything is fine. Why is this the case ?

one of two things:

- You use variable initialization in the init() section, not all functions work correctly there

- maybe you didn't initialize some variable, it has long been considered good programming practice to initialize with at least some value after describing variables

ZS: why do you have ArrHigh[i] array and use ArrHigh[0] ?

 

And one more little question.

I came across the following entry:

 void IncArray( int & Array[] )

Everything seems to make sense, except what does the & sign mean in this case ?

 
Fox_RM what does the & sign mean in this case ?
https://docs.mql4.com/ru/basis/variables/formal
 

IgorM:

One of two:

- you use variable initialization in init() section, not all functions work properly there

- maybe you didn't initialize some variable, it has long been considered good programming practice to initialize with at least some value after describing variables

.

You are absolutely right, " you use variable initialization in init() section,..." - there is such a sin)

"...any value" - 0 is assigned.

" why do you have ArrHigh[i] array and use ArrHigh[0]..." The point is this.

I need to get the value High[i] to workwith later in the code.

If I make an assignment to a variable in the loop, it will be overwritten during next iterations. I can't think of anything cleverer than assigning

High[i] to an array and then work only with ArrHigh[0]. The next time this loop hits, all the values are reinitialized.

Maybe there is a better option?

 
 
Fox_RM:
1.You are absolutely right, "you use initialization of variables in the init() section,..." - there is such a sin)

2.Maybe there is a better option?

1. you can and sometimes only need to initialize in init() section, I only paid attention to the fact that standard functions will not all work correctly, access to timeseries will work correctly

2. I don't understand why you have to complicate the task? array High[i] will not go anywhere why copy it again? if you're afraid of "losing a bar" when you open a new bar, remember the time of the bar - the time will never change, you can use this construction High[iBarShift(NULL,0,mytime)]

ZS: after the phrase: "If you make an assignment to a variable in the loop, it will be overwritten in the next iterations." I suspect that the problem is in random initialization of some variable, try to print() all the variables in the problematic code section

 
IgorM:
Thanks Igor, I'll try it that way!
 

I have been studying it for a week now.)

i need to prescribe it to open two orders (multi-directional) with a certain stop and profit and then, if i close them, i open other orders with the same exact amount + flow check and only open positions with 8 to 8

Thanks in advance))

 
vkontakte0:

I have been studying it for a week already)).

i need to prescribe it to open two orders (multi-directional) with a certain stop and profit and then, if i close them, i open other orders with the same exact amount + flow check and only open positions with 8 to 8

thanks in advance)))

I think that one textbook is not enough. The IMF has many different sites where the basics of MQL and the basics of "expert writing" are given (I'll send you the links in private if you need them). For example, I have

I downloaded them and converted them to chm format. I have them handy all the time. If I'm going to trade with Expert Advisors I think I'm in a hurry, I need to get acquainted with indices and then complicate the matter IMHO.