Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1026

 
Vladimir Karputov:

The point doesn't change - you are trying to delete a pending order with a ticket "0" on every tick.

And who says that you have a pending order with a "0" tick on every tick? Have you checked how many pending orders there are? And how do you know that ....?

With which tick is "0"??? OrderGetTicket(0) does not mean that an order with ticket 0 is selected, but returns a ticket order from the list of pending orders under index 0.

 
ascerdfg:


You probably need to be more specific in your task.

For example: if there is a pending order whose magic is "1" - then delete it.

In this case, the implementation will be as follows:

#include <Trade\Trade.mqh>

CTrade trader;
int OnInit()
  {

   trader.SetExpertMagicNumber(1);

   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
//---
  
  }
void OnTick()
  {
   for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
      if(OrderGetTicket(i)>0)     // selects the pending order by index for further access to its properties
         if(OrderGetInteger(ORDER_MAGIC)==1)
            trader.OrderDelete(OrderGetTicket(i));
  }

Loop through all pending orders

If a pending order has been successfully selected (the returned value is the ticket greater than zero)

If the magic value of the selected pending order is "1"

Delete it

 
Alexey Viktorov:

With which ticket "0"? OrderGetTicket(0) does not mean that an order with ticket 0 is selected, but returns a ticket of an order from the list of pending orders under index 0.

Yes, that's right.

 

Can you tell me how much RAM is needed to run the tester for 30 characters from 2004 to today?

The tester says there is not enough, but it doesn't say how much is needed.

 
Igor Zakharov:

Can you tell me how much RAM is needed to run the tester for 30 characters from 2004 to today?

The tester says there's not enough, but it doesn't say how much.

Run two characters, five characters ...

 
Vladimir Karputov:

Run two characters, five characters ...

That's not really the question - how much memory do I need to buy to make such a test possible?

here's the result for one symbol (from the log in opening price mode)

264  Mb memory used including 6 Mb of history data, 64  Mb of tick data

here's 2:

271 Mb memory used including 12 Mb of history data, 64 Mb of tick data

3:

1038  Mb memory used including 12 Mb of history data, 832 Mb of tick data

And here's 4:

1450 Mb memory used including 18 Mb of history data, 1216  Mb of tick data

It wentexponentially:) I can't trace the logic, as the ticks are about the same:

EURUSD,H1: 21470549 ticks, 94233 bars generated. 63097850 total ticks for all symbols
EURUSD: generate 21470549 ticks in 0:00:05.375, passed to tester 21470549 ticks
USDCAD: generate 20302871 ticks in 0:00:05.062, passed to tester 20302871 ticks
USDJPY: generate 21324430 ticks in 0:00:05.641, passed to tester 21324430 ticks
1450 Mb memory used including 18 Mb of history data, 1216 Mb of tick data

I've seen many reports of 20 or more characters, I do not believe that someone uses terabytes of RAM. Maybe there is a secret?

 

Is it possible to set the number of graphical buffers in the indicator?

And the second question, is there a possibility of forced reinitialization of the indicator used by the Expert Advisor in order to save RAM?

 
Aleksey Vyazmikin:

Is it possible to set the number of graphical buffers in the indicator?

And the second question, is there a possibility of forced reinitialization of the indicator used by the Expert Advisor in order to save RAM?

It is possible to decrease the number of indicator_plots stated in #property indicator_plots, I did it. But it is hardly possible to increase it. But this decrease will not lead to memory saving. After all, buffers remain. They are just transferred from INDICATOR_DATA to INDICATOR_CALCULATIONS and nothing more.

 
Alexey Viktorov:

The stated in #property indicator_plots can be reduced, I did that. But increasing it is unlikely to be possible. But this reduction will not save RAM. The buffers remain, after all. They are just transferred from INDICATOR_DATA into INDICATOR_CALCULATIONS and nothing more.

Thank you for your reply. A cosmetic change to the number of buffers is not relevant, unfortunately.

 

I want to get MACD indicator handles from three timeframes in the OnInit() block. On the chart - it works, but in the tester it doesn't work, and the terminal hangs tight! So I want to get the data that doesn't exist? Can you please advise how to deal with it?


//+------------------------------------------------------------------+
//|                                                        Test.mq5  |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

//--- Количество периодов торгуемых символов
#define  NUMBER_OF_PERIODS 3

ENUM_TIMEFRAMES Periods[NUMBER_OF_PERIODS]={PERIOD_M1,PERIOD_M2,PERIOD_M3};
int handles[NUMBER_OF_PERIODS];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   ArrayInitialize(handles,INVALID_HANDLE);
      for(int p=0; p<NUMBER_OF_PERIODS; p++)
        {
         if(handles[p]==INVALID_HANDLE)
           {
            handles[p]=iCustom(NULL,Periods[p],"Examples\\MACD");
            Print(handles[p]);
            if(handles[p]==INVALID_HANDLE)  Print("Не удалось получить хэндл индикатора для символа !");
           }
        }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+
Reason: