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

 
Alexander Layzerevich:

Can you tell me how to replace it in MQL5 ?

datetime  TimeCurrent(
   MqlDateTime&  dt_struct      // переменная типа структуры
   );


And then read the contents of the structure. It works the same in mql5 and in mql4

struct MqlDateTime
  {
   int year;           // год
   int mon;            // месяц
   int day;            // день
   int hour;           // час
   int min;            // минуты
   int sec;            // секунды
   int day_of_week;    // день недели (0-воскресенье, 1-понедельник, ... ,6-суббота)
   int day_of_year;    // порядковый номер в году (1 января имеет номер 0)
  };
 
Igor Makanu:

this article will help youhttps://www.mql5.com/ru/articles/81

Thank you.

 

Due to the limitation on the number of open positions at the broker, I had to split the portfolio into 2 accounts in order to open the whole portfolio. Could you please advise me how to organise a trawl of the aggregate position of the two accounts?

Thank you in advance.

 
Can you advise a newbie... i downloaded a free indicator.... from Market... i attached it to a chart... when i switch from one time period to another, the indicator is displayed with a big delay (i.e. it slows down)... what could be the problem? Thanks...
 
net150:
Please advise a beginner... i downloaded the free indicator.... from Market... when i switch from one time period to another, the indicator is displayed with a big delay (i.e. it slows down)... what could be the problem? Thanks...

Too much data to calculate, or the indicator is not written optimally. It happens.

 
How to write a function for the robot to roll over in case of loss. For example went in minus 20 points and flipped and if again in minus, then again flip. Please help.
 
Ivan Kopchuk:
How to write a function that would cause the robot to roll over in case of a loss. For example has gone in minus 20 points and flipped and again in minus again flips. Please, help me.

You close a position as soon as it reaches -something and immediately open it in the opposite direction from the closed one.

0 You take all orders (OrdersTotal), look through them (OrderSelect), in order to see, if there is already an open position in this TS
1.1 If there is already an open position, note the order ticket (OrderTicket)
1.2 If not - you open a position (OrderSend), save the ticket of this position into a variable, set take and stop points if needed (OrderModify)
2 Check the current profit (difference between OrderOpenPrice and Bid or Ask), until one of the following conditions is met
2.1 If the profit has reached the set loss - close the position (OrderClose) and open a new one in the other direction, remember the ticket, then continue with point 2
2.2 If the profit reaches the required value, close the position, reset the ticket, open a new position by the rules of entering TS, save the ticket of this position in the variable, and go to point 2

https://docs.mql4.com/ru/trading

 
Ilya Prozumentov:

You close the position as soon as it goes to -something and immediately open it in the opposite direction from the closed position.

0 You take all orders (OrdersTotal), look through them (OrderSelect), to see if there is already an open position for this TS
1.1 If there is already an open position, note the order ticket (OrderTicket)
1.2 If not - you open a position (OrderSend), save the ticket of this position into a variable, set take and stop points if needed (OrderModify)
2 Check the current profit (difference between OrderOpenPrice and Bid or Ask), until one of the following conditions is met
2.1 If the profit has reached the set loss - close the position (OrderClose) and open a new one in the other direction, memorize the ticket, continue with point 2
2.2 If the profit reaches the required value, close the position, reset the ticket, open a new position by the rules of entering TS, save the ticket of this position in the variable, and go to point 2

https://docs.mql4.com/ru/trading

Thank you.

 

Greetings. Could you give me a hint?

How does the condition hold when a variable with a negative value(summ)>= a variable(profit) equal to zero?

summ=(double)(H_SellMinProfit()+BuyProfit()-SpreadCost());
      if(summ>=profit)
         CloseOll();st=1;max_level=level;min_level=level;  Print("st=1", "  H_SellMinProfit() ", H_SellMinProfit(), "  BuyProfit() ", BuyProfit(), "  SpreadCost() ", SpreadCost(), "  ++- ", H_SellMinProfit()+BuyProfit()-SpreadCost(), "  summ ", summ, "  profit ", profit);


Whole code,

Files:
Ivanov4.mq4  20 kb
 
Andrey Sokolov:

Greetings. Could you give me a hint?

How does the condition hold when a variable with a negative value(summ)>= a variable(profit) equal to zero?

Whole code,

summ=(double)(H_SellMinProfit()+BuyProfit()-SpreadCost());
  if(summ>=profit) {
    CloseOll();
    st=1;max_level=level;min_level=level;
    Print("st=1", "  H_SellMinProfit() ", H_SellMinProfit(), "  BuyProfit() ", BuyProfit(), "  SpreadCost() ", SpreadCost(), "  ++- ", H_SellMinProfit()+BuyProfit()-SpreadCost(), "  summ ", summ, "  profit ", profit);
  }
Reason: