Questions from Beginners MQL5 MT5 MetaTrader 5 - page 765

 
Alexey Kozitsyn:

The mouse movement event is definitely not generated. With the others, I think it's the same.

And in the EA?
 
Artyom Trishkin:
And in the councillor?

Same thing...

 
Alexey Viktorov:

The answer was given before...

But it's better not from-a-light quantity, but about the maximum to try to get by with one copy.

I won't write an example code. A normal programmer just needs a hint. Here is an approximate algorithm:

  1. We determine the approximate number of bars at which the channel is crossed. Let it be 15.
  2. Copy both buffers of the indicator.
  3. Copy the values of bars using CopyRates()
  4. In the loop, we start comparing the values of the upper limit of the channel and high bars simultaneously with comparing low bars with the lower limit of the channel. If one of these crossings is found, the bar index is stored in a variable, and we continue to look for the second crossing. We exit the loop when both variables of intersection bars have values.

Thus, it is possible to find two intersections in one copy and one cycle, if necessary. There is even no need in ArraySetAsSeries() because when finding the crossing it is possible and, in my opinion, better to remember the time of bar, not its number. Although, knowing the time of the bar, there is no difficulty in determining its number.

Question: What will be faster, a cycle with copying of the indicator buffer by 1 value and copying of high bar by 1 and comparing those values, or a single copy of a certain amount and comparing values of the two arrays with each other?

I suggest not to deviate from the concept, which, as I understood it, was to copy a certain amount of bar data at the beginning of the code, and then work with this data - or do you suggest an exception?

And, what makes you think I'm a programmer?

I don't think you need to guess - what will be faster, sometimes the answer may not be obvious - only experience can give an answer to such questions.


 
Vladimir Karputov:

Just wrote this yesterday:

Task:

on each tick get "InpCountCopy" elements open, high, low, close and time.

Implementation:

  1. loop from "0" to "InpCountCopy-1" - the loop gets one open, high, low, close and time at a time.
  2. At one time we get "InpCountCopy" elements into MqlRates structure and then loop through the structure.

Features:

it is possible to choose how to check: in OnTick or in OnTimer (1 second).

Thank you, I will try to make sense of the code.
 

Tell me why this code finds a ticket that is not already in the history

  HistorySelect(0,TimeCurrent()); 
  for(int i=HistoryOrdersTotal()-1; i>=0; i--) {
   string OrdTick=IntegerToString(HistoryOrderGetTicket(i));
   if(OrdTick=="63425010") Print(OrdTick);
  }
2017.07.24 23:58:33.514 RE (EURGBP.m,H1)      63425010


 
Vitaly Muzichenko:

Tell me why this code finds a ticket that is not already in the history


Have you tried to search for a closed trade (OUT)? There was an order - you can see it.

 
Vitaly Muzichenko:

Tell me why this code finds a ticket that is not already in the history


That's right :

You are looking for an Order , and the Order to open Position = 63425010 has already done its own , and it is in History.

And I think the Ticket Order and Ticket Position are the same, which misled you.

If you want to analyse the Position, use PositionSelect(), then analyse its properties.

 

What is needed:

We send an order, in response we receive a position ticket, then an object named "position ticket" is drawn on the chart (no replacement is specified). If we open several positions, respectively, there are several objects with ticket names on the chart, and if we then close one of them, all objects are deleted, while we only need to delete the object with the closed ticket from the history. The delete function works on OnTrade

 
Vitaly Muzichenko:

What is needed:

We send an order, in response we receive a position ticket, then an object named "position ticket" is drawn on the chart (no replacement is specified). If we open several positions, respectively, there are several objects with ticket names on the chart, and if we then close one of them, all objects are deleted, and we only need to delete the object with the closed ticket from the history. The delete function works on OnTrade


So what do you need, a ticket of an order or a ticket of a position?

 
prostotrader:

So what do you need, an order ticket or a position ticket?

You need to delete objects with a ticket that are already in the history, but not those that are still in the market

Duplicate:

  HistorySelect(0,TimeCurrent()); 
  for(int i=HistoryOrdersTotal()-1; i>=0; i--) {
   string OrdTick=IntegerToString(HistoryOrderGetTicket(i));
   if(OrdTick=="63425010") Print(OrdTick);
  }
2017.07.24 23:58:33.514 RE (EURGBP.m,H1)      63425010