Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1276

 

Help me figure out why the code doesn't change the global variable.

I call it in OnTick event


Here is such a code fragment:


  //+------------------------------------------------------------------+
         if(Main_reverse_upside_short)
           {
            double price = m_symbol.Ask();
            make_trade.PositionClose(m_position.Ticket());
            Alert("Закрываем лонг);
            make_trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, FixedLot, price,0,0, "Переворачиваем шорт в лонг");
            GlobalVariableSet(Nonloses, 1.0);
            return;
           }

On the next tick, the global variable Nonloses becomes 0 again.

At the same time, if we address it inside the same If condition, it will equal 1 inside. So, it looks like an ordinary variable which is not outside a block, but it is a global variable?

Where am I wrong?

 
SanAlex:

Select on the website (copy the name)-and ( Ctrl+V )-type in search in the terminal

Thank you!
 
Friends, please help.
 
Mahadich:

Help me figure out why the code doesn't change the global variable.

I call it in OnTick event


Here is such a code fragment:


On the next tick, the global variable Nonloses becomes 0 again.

At the same time, if we address it inside the same If condition, it will equal 1 inside. So, it looks like an ordinary variable which is not outside a block, but it is a global variable?

What am I wrong about?

You showed the wrong piece of code. Somewhere there is an assignment of 0 to a variable without any conditions, or by some condition that is fulfilled right after this piece of code.

 

Good day to you all.

Can you advise how to fix this situation?

According to the manual :

CHARTEVENT_OBJECT_CLICK

Mouse click on graphical object


Actually, the reaction to this command happens after releasing the mouse button, i.e. pointing at the object, click, no reaction, release, there is a reaction.

Is it possible to make the reaction, exactly, on the mouse button press ?

 
SanAlex:

You don't have them on your profile.

Bad answer... if not worse....

 
SanAlex:

Whatever the question, that's the answer.

The question is fine. Another thing is that the questioner didn't bother to search for the answer in the first place... But the answer is out of line... Why do you personally care how many "Friends" he has in his profile?

 
SanAlex:

and that I crossed you - and anyway, sometimes you have to understand jokes

And put yourself in the person's shoes. And read your own answer. This is a tech forum, not a comedy forum! Soda does not come here to "laugh"!

 
SanAlex:

Question and answer - I didn't mean any harm, just that the question wasn't complete.


Is the reference to "Friends" nonsense? Is it only to actual friends? In that case it would have been easier for him to go out into the yard and ask the question there.

The address is respectful - your answer is.... Bad answer. On either side!

And let's stop flubbing.

 
SanAlex:

Deleted all correspondence - maybe I did offend you in some way - Sorry if I did!

)))))))

There's no need for a comma here )))

"Something" is hyphenated - "something".

The situation under discussion, your answer to the question, has nothing to do with me directly. Just don't "humour" in unnecessary places ))))