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

 
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 the compiler swears "variable already defined" when rec declaring a variable in another scope. 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 even up my hands?

And where did you find "another scope"? In a new line?

All within the same function. So unambiguously - hands ... :)

How do you level your arms? With a hundred...
 
Qoren:

Hello.
I am writing an EA in mql4. At a certain moment, it draws a standard Fibonacci channel with 4 levels and a horizontal line which intersects the Fibonacci channel with all its levels.

I've been reading Yandex, tutorials and google for 5 hours. Please, help me to find crossing of horizontal line with one of Fibonacci levels of the channel. I know 3 coordinates of channel construction, I know levels (0.15, -0.15), I know price of horizontal line. Please advise how to find coordinates and assign them to variables of two arbitrary points lying on one of the lines-levels of the channel.

How about the straight line equation to help you?

//+----------------------------------------------------------------------------+
double EquationDirect(double x1, double y1, double x2, double y2, double x) {
  if (x2==x1) return(y1);
  return((y2-y1)/(x2-x1)*(x-x1)+y1);
}
//+----------------------------------------------------------------------------+
x1, y1 - coordinates of the first point; x2, y2 - coordinates of the second point; x - value for which to calculate y.
 
Alp:

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.

You are in luck. If you have a profit, you should close it when the terminal calculates 2 cents per point. If you have a loss, you should close it at 1 cent per pip.

I'm not so lucky: only 1 cent a point and not a cent more.

 
Reshetov:

You are in luck. If a position is in profit, you should close it when the terminal calculates 2 cents per point. And when in a loss, you close it at 1 cent a pip.

I'm not so lucky: only 1 cent a pip and not a cent more.

You're the lucky one who can calculate properly.
 
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 is a script (so as not to bother)

It's hard to understand someone else's code at once... If I had to guess, I would check Imin,Imax,Jmin,Jmax values in Neuron.Study() function. On epoch 0, value 32 is passed as lR, which is then used in indexing (usually we index arrays from 0 to size-1). It is quite possible that this is where the error lies.
 

Saw it on a website somewhere, but can't find it.

What is the difference between a stop order and a limit order?

 
Alp:

Saw it on a website somewhere, but can't find it.

What is the difference between a stop order and a limit order?


https://book.mql4.com/ru/appendix/limits
 
 
Roman.:


Will you be opening positions from the market?

+ possibility of selecting a market order or buy or sell so?

No, of course we should open positions using buy or sell orders at the opening of the next or one of the following bars. And I also plan to close by an order, assigning it by the number of points from the opening.
 
Tried to create an EA based on a coin, heads buy, tails sell. But it doesn't work. When testing in a window there is an inscription: When opening the order error 131, in the application looked - it is not the correct volume. I looked carefully, I cannot find any error. There is a dot everywhere, to separate the integer part, not a comma. Please help. The code is in the file.
Files:
ihnexax.mq4  5 kb