Questions from Beginners MQL5 MT5 MetaTrader 5 - page 743

 

Hello all! Question about MQL5.

I would like to insert comments into the function of closing a position in a ticket.

So far I've used CTrade class, but it does not provide such an opportunity.

I.e. I need to use OrderSend, right?

Here I don't understand: https://www.mql5.com/ru/docs/constants/tradingconstants/enum_trade_request_actions#trade_action_deal in the example the OnStart function is written. Or may I write everything in custom function and call it when necessary?

Is it necessary to add something to OnInit?

And won't there be conflicts if I write the closing through OrderSend and leave opening and modifications on the basis of CTrade class?

Thank you!

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Типы торговых операций - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:

Roughly speaking - read carefully what I wrote to you and drop the infinite loop from your code.

Are you sure that putting the Expert Advisor into an infinite loop is the right solution?

Firstly, this is not a solution, but an example to demonstrate the essence of what I am talking about.

Secondly, it's not an infinite loop, it will correctly and safely terminate when the program ends.

And thirdly, you're writing to me about solving a completely different thing, for which I can think of a million ways.

So you consider my loop to be a stumbling block to my situation? Really?

Anyway, I get it. I had a bad trip into this thread...

But thanks anyway!

 
Marat Sultanov:

Firstly, this is not a solution, but an example to show the essence of what I am talking about.

Secondly, it's not an infinite loop, it will correctly and safely terminate when the program ends.

And thirdly, you're writing me about solving a completely different thing, for which I can think of a million ways.

So you consider my loop to be a stumbling block to my situation? Really?

Anyway, I get it. I had a bad trip into this thread...

But thanks anyway!

At the end of the program, yes, it will be interrupted.

Make some really heavy calculation then, and try to interrupt it when the settings window is called.

I looked at how your code works - it doesn't respond to a change of variable in settings - it is prevented by infinite loop, which can only be interrupted by removing the EA, and it will not start again - you deleted it from the chart...

Try to keep track of the heavy calculation via timer. Although I'm not sure if the timer will be called at the moment of calculation.

But in any case, looping to emulate a long calculation is not a good solution.

 
Hello. Could you please tell me how to set an array in the input parameters of a function?
double test[];


double Test(.....)
{

}
 
Fresto:
Hello. Can you please tell me how to set an array in the input parameters of a function?

Pass an array to a function?

It goes something like this:

//+------------------------------------------------------------------+
double test[];
ArrayResize(test,2);
ArrayInitialize(test,256);

Print(Test(test));
//+------------------------------------------------------------------+
double Test(double &array[])
{
   if(ArraySize(array)==0) return(WRONG_VALUE);
   array[0]+=array[1];
   return(array[0]);
}
//+------------------------------------------------------------------+

Well ... variations on the theme ...

 
Artyom Trishkin:

When you terminate the program, yes, it will.

Then make some really heavy calculation and try to interrupt it when the settings window is called.

I looked how your code works - it doesn't react to variable changes in settings - it is not allowed to do so by infinite loop, which can only be interrupted by removing EA, and it will not start again - you deleted it from the chart...

Try tracking a heavy calculation with a timer. I'm not sure if the timer will be called at the time of the calculation though.

But in any case, looping to emulate a long calculation is not a good solution.

Thanks!

Understood. But unfortunately there is a reasonable need.

But in any case, looping to emulate a long calculation is not a good solution.

There are situations, when for example it is necessary to write to a big file or read from a big file or all together. If you stretch your imagination, you can get a lot of batshit crazy, and the pain is squared when you implement it :)

I find it strange, that the possibility to trace an interrupt with _StopFlag is there, but there is no change of input parameters :(

 
hello, question: is it possible to change the angle at which the comment is displayed on the graph?????
 
Dmitry Melnichenko:
hello, i have a question. is it possible to change the angle of the comment on the chart?????

No.

Unless you create a graphic label OBJ_LABEL yourself and change its property

OBJPROP_ANGLE


using the function:ObjectSetDouble
 
Guys, help with the indicator
Files:
llassiff.mq5  17 kb
 
Rafael Sahibgareev:
Guys, help me figure out the indicator
There's a piece of code in there that I don't understand. You need to correct it yourself.
Files:
llassiff.mq5  18 kb
Reason: