Table of all trades. Accessed via MQL5 - page 2

 
prostotrader:
Found a bug and optimised the operation.

A good example, although there is still a long way to go before optimum performance. So far, the main brakes are three:

1. CopyTiks every OnBookEvent copies all the ticks since the start:

int copied= CopyTicks(Symbol(),ticks,COPY_TICKS_ALL,start_time,0);

This can actually be optimised by making dynamic cutoffs.

2. Full enumeration of all received ticks in OnBookEvent

for(int i=1; i<copied; i++)
{
   if(( ticks[i].flags  &TICK_FLAG_BUY)==TICK_FLAG_BUY)
   {
      buy_deals++;
   }
   else
   if(( ticks[i].flags  &TICK_FLAG_SELL)==TICK_FLAG_SELL)
   {
      sell_deals++;
   }
}

This too can be fixed if you wish.

3. Complete enumeration of all bars in OnCalculation:

for(int i=rates_total-1; i>0; i--)
{
   SellBuffer[i]= SellBuffer[i-1];
   BuyBuffer[i] = BuyBuffer[i-1];
}
 
At the request of forum members, I have finalised the indicator
Files:
DealsLent.mq5  9 kb
 
Vasiliy Sokolov:

A good example, although there is still a long way to go before optimum performance. So far, the main brakes are two:

1. CopyTiks every OnBookEvent copies all the ticks since the start:

This can actually be optimised by making dynamic cutoffs.

2. Full enumeration of all received ticks in OnBookEvent

This too can be fixed if you wish.

3. Complete enumeration of all bars in OnCalculation:

Thanks, but you're not right everywhere.

1. Not all ticks (look carefully).

2. how do you want to do it?

3. easy to do

Now, let's tweak it...

 
Here, tweaked.
Files:
DealsLent.mq5  9 kb
 
prostotrader:

Thank you, but you are not right about everything.

1. Not all ticks (look carefully)

2. easy to do

3. easy to do.

Now we're getting it right...

Yes, indeed not all ticks.

About the third point, I'm not sure it will be easy to do. The indicator is tickwise and therefore requires serious re-rendering.

But on the whole it is OK. Thanks for the example.

 
prostotrader:
Here, I tweaked it.
Thank you.
 
Vasiliy Sokolov:

Yes, indeed not all ticks.

About the third point I'm not sure it would be easy to do. Because the indicator is a tick indicator and therefore it does require some serious re-rendering.

But on the whole it is OK. Thanks for the example.

Indeed, the indicator is tick based, so only the current data (recent) is important.

If user wants to take longer history from buffers,

it is very easy to do.

Sec.

 

Here, the user can choose the size of the data they are interested in.

If ActSize = 0 - all available history

Files:
DealsLent.mq5  9 kb
 
The final touch...
Files:
DealsLent.mq5  10 kb
 

Does anyone know what the error is?

The indicator works correctly, but more bars are displayed,

than it was set up for.