Questions from Beginners MQL5 MT5 MetaTrader 5 - page 514

 
Karputov Vladimir:

Снова нет конкретики. Ладно: пальцем в небо - DebugBreak.

Применять примерно так:

Karputov Vladimir
:

Again, no specifics. OK: finger in the sky -DebugBreak.

Apply like this:

OK, What do you need for specifics? I wrote a little earlier.

The point is this:

two pending orders are opened.

One of them will be executed, and the other one will be deleted as it is not needed.

The first one will also close after a while (plus or minus).

The idea is that we return to the starting point. And everything should repeat.

But no.

Before all this process I put:

   b1 = OrdersTotal();                                      //количество ордеров               
   c1 = PositionSelect(_Symbol);                            //наличие позиции

If both are zero, we execute the circuit, if not, we don't.

In debugging, I put these two points in the observation. Both of them are 0. But on the second round only one order is placed.

Why is it so?

 
kashi_ann:

OK, what do you need for specifics? I wrote earlier.

Here's the idea:

2 pending orders are opened.

One is executed, the other is deleted when it is not needed.

The first one will also close after a while (plus or minus).

The idea is that we return to the starting point. And everything should repeat.

But it does not.

...

Your logic, you have to answer the question yourself.

kashi_ann:

...

In debugging, I put these two items in the observation. They're both 0. But on the second round, only one order is placed.

Why is it so?

Again, only you can answer, as the logic is yours.

In general, I would like to repeat it once again: a correctly formulated question contains 90% of the answer. So please put breakpoints before the place in the code where you take action with the position. And then step-by-step debugging.

 
toni_stark:
Hello, Could you please suggest the code which performs the action at the beginning of a new day (00.00), or in other words, how to display the condition "If a new day occurs (00.00)" in MQL?

There are two mql languages.

The algorithm is as follows:

Remember the time of the previous candle in TF D1 in a static variable and compare it with the time of the current candle in the same TF. If the time has changed, then perform the action and remember the time of a new candle in the same variable.

 
Isthe static variable present in MQL4?
 
toni_stark:
Hello, Could you please tell me the code which will cause the EA to execute some action at the beginning of a new day, i.e. 00.00, or in other words, how to display the condition "If it is a new day (00.00)" in MQL?

Alternatively

if (StatTime==1)

 Time=iTime(NULL,1440,0);

 StatTime=0;

 }

       if(Time!=iTime(NULL,1440,0))

           {

  StatTime=1;

           } 

 
-Aleks-:

Alternatively

if (StatTime==1)

 Time=iTime(NULL,1440,0);

 StatTime=0;

 }

       if(Time!=iTime(NULL,1440,0))

           {

  StatTime==1;

           } 

It is not entirely clear what type of StatTime variable it is?
 
toni_stark:
It is not quite clear what type of StatTime variable it is?

datetimeTime

intStatTime

There was a misprint in the code: notStatTime==1; butStatTime=1;

       if(Time!=iTime(NULL,1440,0))

           {

  StatTime=1;

           }  

 
Karputov Vladimir:

Your logic, you should answer the question yourself.

Again, only you yourself can answer, because the logic is yours.

In general, I will repeat it once again: a correctly posed question contains 90% of the answer. In general, put breakpoints before the place in the code where you take action with the position. And after that you do step-by-step debugging.

Yeah, so it's just a question of logic. I was more concerned that apart from the order of actions, I also have to take into account the time of data update on the server.

I usedbreakpoints of course.

I guess I'll have to rewrite the whole thing, it looks like nonsense.
 
Is anyone here from Ufa?
 

2016.02.15_14:27 GMT+3. Hello, question for the moderators. I am attaching

screenshot. Can't get ZigZag's indicator buffer data. On

I can see in the screenshot that I have the "indicators" folder in the file path. In fact

There is actually a folder "Indicators" in the terminal. Perhaps because of this discrepancy and

I can't open the ZigZag.mq4 file.
And data of Moving Average and Fractals indicators how to get into arrays, not

only the latest values? Any tips. That's all for now. Waiting for an answer. 14:36 GMT+3. 15:25 GMT+3.

Written in procedural programming.