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

 

Greetings.

I would like to ask about the visibility areas in MQL4. Here's a piece of code:

if (0==0)
{
  if (1==1)
  {
    int var1 = 0;
  }
  if (1==1)
  {
    int var1 = 0;
  }
}

I wonder why all of a sudden when a variable is re-declared in another scope, the compiler swears "variable already defined". I don't believe him, of course, but he doesn't care much about this fact.

Well, actually, I understand there shouldn't be such a thing since there are different scopes and so on. This is a clever trick or my hands are very crooked? I'd really want a variable to die with a sense of accomplishment when leaving the scope it was defined in. How do I level my hands?

 
Vinin:

I'm tempted to ask a question of my own as well

In the picture the top line is quite different from the second, which should not be

Attached script (so as not to bother)


So what's the question?

ZS. Beautiful!

 

ns88ns:

In general, as I understand it, this shouldn't be the case, because different scopes and all. Is it such a clever feature or my hands are very crooked? I really want the variable to die with a sense of accomplishment when leaving the scope it was declared in. How do I even up my hands?

It will not work in this case. If a variable is declared in a function, it will exist until the function terminates.
 
ns88ns:

Greetings.

I would like to ask about the visibility areas in MQL4. Here's a piece of code:

I wonder why all of a sudden when a variable is re-declared in another scope, the compiler swears "variable already defined". I don't believe him, of course, but he doesn't care much about this fact.

Well, actually, I understand there shouldn't be such a thing since there are different scopes and so on. This is a clever trick or my hands are very crooked? I'd really want a variable to die with a sense of accomplishment when leaving the scope it was defined in. How do I level my hands?


Yeah, well... and there's nothing to say... better to be silent...

Or write your own language with your rules !

 
FAQ:


Yeah, well... nothing to say... better to be silent...

Or write your own language with your rules !


But you couldn't :-)

Mercy, there are no My rules. I got my template ripped up, I asked how come... It turned out that my hands are straight, and this feature is a buy design. No claims and no need to have your own language :-) Besides, this nuance is documented, as it turned out.

Thanks to all the respondents.

 

Hello.
I am writing an EA in mql4, at some point the EA draws a standard Fibonacci channel with 4 levels and a horizontal line, which at some point necessarily crosses the Fibonacci channel with all its levels.

Been smoking Yandex, tutorials and google for 5 hours. Help me to find the crossing of the horizontal line with one of the Fibonacci levels, I know 3 coordinates of the channel, I know the levels (0.15, -0.15), I know the price of horizontal line. Please advise how to find coordinates and assign them to variables of two arbitrary points located at one of the channel levels.

 
FAQ:


So what's the question?

ZS. Beautiful!


Don't like the way the first line is drawn
 

Good evening. I am writing an indicator and I have the following problem: We have some range higth or low. How to calculate the value of the level with the highest density of higth or low, i.e. the level at which there are a lot of these values. (By analogy with support and resistance)

 
Skydiver:

Good evening. I am writing an indicator and I have the following problem: We have some range higth or low. How to calculate the value of the level with the highest density of higth or low, i.e. the level at which there are a lot of these values. (By analogy with support and resistance)

The first thing that comes to mind is to determine a confidence interval, where these high and low values are relevant, i.e. when they are high and when they are low... So, we are talking about a cloud of the confidence interval... I.e. For example, suppose you set some "channel width" of these values through external variables, for high and for low, then count number of times they hit in corresponding "channels" for some period of time... Then, remember any high and low of these channels - as a result, you draw resistance and support. That's it. If you need more precise drawing of these lines, then you memorize these values in arrays, and then find the average value of these arrays - they will be the support and resistance lines.

I don't exclude that there is some easier way of doing this.

 

Help me to set a take profit

The problem is this: let's say I buy 0.01 lot in EUR/USD at 1.31000 (deposit in EUR).

I have to set Take Profit to a value when the profit will be 1 euro. How do I calculate it?

I cannot do it, because sometimes 1 point movement adds 1 euro or 2 euro.

If growth of 1 pip would bring 1 euro cent.

we take a profit of 100 pips + cummerbund (17 points) + broker's fee (16 pips) and TP should be set to 1.31133.

But 1 point adds 1 euro cent or 2 euros. If I got 0.02 lots then it changes more unclear.

How do I calculate take profit value?

Reason: