[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 345

 
alsu >> :

OrderSelect (0,SELECT_BY_POS, MODE_HISTORY) - selects the last order in the history

OrderSelect (1,SELECT_BY_POS, MODE_HISTORY) - the last but one order

accordingly, you can find out OrderProfit() for each of them


many thanks

 
Actually the last one is OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS, MODE_HISTORY)
 
vademur писал(а) >>

Please advise what caused the error and how to deal with it, occurs in the tester's log:

19:20:11 TestGenerator: unmatched data error (low value 1.3676 at 2009.05.13 00:00 and price 1.3676 mismatched)
19:20:11 TestGenerator: unmatched data error (high value 1.3696 at 2009.05.13 01:00 and price 1.3696 mismatched)
19:20:11 TestGenerator: unmatched data error (high value 1.3700 at 2009.05.13 02:30 and price 1.3700 mismatched)
19:20:11 TestGenerator: unmatched data error (high value 1.3700 at 2009.05.13 03:30 and price 1.3700 mismatched)

I tried deleting prices and uploading again, maybe I'm doing something wrong, everything seems to be fine in the code.

Let me rephrase the question. Where can I get a good history or where can I read about it?

 
alsu >> :
Silen wrote (a) >>

First of all, learn to answer correctly. Comments like yours are of no use to anyone.

The error was returned by GetLastError() after running iTime(). Here's a sample code...

//+------------------------------------------------------------------+
//|                                                   test_iTime.mq4 |
//+------------------------------------------------------------------+
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
    
    for(int i = 20; i > 0; i--)
    {    
      CheckTF(PERIOD_M5, i);    
      CheckTF(PERIOD_M15, i);
      CheckTF(PERIOD_M30, i);
    }
   return(0);
  }  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   
//----
   return(0);
  }
//--------------------------------------------------------------------  
int CheckTF(int TF, int Index)
  {
    int count = 5;   
    int err;     
    int xBars;
   
   xBars = iBars(Symbol(), TF);
   err = GetLastError();
   while ( err == 4066)
   {
      Sleep(200);
      xBars = iBars(Symbol(), TF);
      err = GetLastError();
   } 
    err = GetLastError();
    datetime t0 = iTime(NULL, TF, Index);
    err = GetLastError();
    
    if( err > 0 && count >0)
    {
      Print("Error: ", err," TF: ", TF," Index: ", Index , " count: ", count);
      Sleep(200);
      count--;
      
      t0 = iTime(NULL, TF, Index);
      err = GetLastError();      
    }
   return(0);
  }  
//+------------------------------------------------------------------+
 
Roger >> :
Actually the last one is OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS, MODE_HISTORY)

Yes, that's right, I've already answered it myself in the same thread :))) https://www.mql5.com/ru/forum/111497/page227#204964

 
Silen >> :

The error was returned by GetLastError() after running iTime(). Here's a sample code...


Tested.

While executing the init() function, the new symbol data may be (and obviously are) not available yet. Hence the error. There is only one way to fight it - do not try to analyze data in the init() function.

 
alsu >> :

Tested.

During init() execution, the new symbol data may be (and obviously is) not yet available. Hence the error. There is only one way to fight it - do not try to analyze data in the init() function.

Thanks, but is there a guarantee that the data will be available in start()?

 

Looking for a script or indicator to see the distribution of tick volume directly on the bar.

like in this picture from the branch Have you seen this picture?


 

Good afternoon, could you please tell me

if(OrderSelect(0, SELECT_BY_POS,MODE_HISTORY)==true)
{
double x=OrderProfit();
Print("last ",x);

}

I need the profit of the last closed order but it is the very first one.

 
vik-777 >> :

Good afternoon please advise

if(OrderSelect(0, SELECT_BY_POS,MODE_HISTORY)==true)
{
double x=OrderProfit();
Print("last ",x);

}

I need a profit of the last closed order but it is the very first one, what is wrong in the code?

Above...

https://www.mql5.com/ru/forum/111497/page345#245944

Reason: