Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 139

 
Forexman77:
Can you tell me how to find the absolute maximum and minimum on the history with the strategy tester?
Maximum and minimum of what?
 
paladin80:
Maximum and minimum of what?

In the history of EURUSD, the maximum and minimum prices of the day. The time of their formation.
 
Forexman77:

EURUSD history maximum and minimum prices for the day. The time of their formation.
Read iHighest and iLowest
 
paladin80:
Read iHighest and iLowest

Finding through iHighest and iLowest is not a problem. How to bake this into the tester so that it gives information on formation time, on a particular history.
 
Forexman77:

Finding through iHighest and iLowest is not a problem. How to bake this into the tester so that it gives information on the time of formation, on a particular history.

You can try it this way:

 for (int i=0; i<iBars(Symbol(),PERIOD_D1); i++) {
  double HistoryMaximum=iHigh(Symbol(),PERIOD_D1,i);
  double HistoryMinimum=iLow(Symbol(),PERIOD_D1,i);
  Print("Дата ",TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE)," Максимум=",DoubleToStr(HistoryMaximum,Digits)," Минимум=",DoubleToStr(HistoryMinimum,Digits));
 }

 
Forexman77:

Finding through iHighest and iLowest is not a problem. How to get this into the tester, so that it gives information on the time of formation, on a particular history.

double High_price=-1.0;
double Low_price=10000000000.0;
double Time_high_price, Time_low_price;
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
//----
   if (iHigh(NULL,PERIOD_M1,0)>High_price)
   {
     High_price=iHigh(NULL,PERIOD_M1,0);
     Time_high_price=iTime(NULL,PERIOD_M1,0);
   }
   
   if (iLow(NULL,PERIOD_M1,0)<Low_price)
   {
     Low_price=iLow(NULL,PERIOD_M1,0);
     Time_low_price=iTime(NULL,PERIOD_M1,0);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Print("Highest price = ",DoubleToStr(High_price,Digits)," on ",TimeToStr(Time_high_price,TIME_DATE|TIME_SECONDS));
   Print("Lowest price = ",DoubleToStr(Low_price,Digits)," on ",TimeToStr(Time_low_price,TIME_DATE|TIME_SECONDS));
//----
   return(0);
  }
 
Sepulca:

You could try it this way:


How can I make the minimum and maximum times be displayed separately? Or rather, it is not a problem. There are several lines for each time in the logbook.

What could be the problem? How to make one line output per value. Ideally, you want a time in numbers that can be copied into excel and compared by

match.


 
Please send me a link to an article on how to set up signals for MetaTrader 4
 

Again, my delete pending orders function does not delete everything. Moreover, it doesn't delete everything in the tester. Help me to understand what is wrong with it.

void DeletePendingOrders()
{
    int numberOfTry = 0,
        err,
        ticket;

   for (int i=OrdersTotal()-1; i>=0; i--)
   {
      if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if (OrderMagicNumber() != i_magic) continue;
      if (OrderSymbol() != Symbol()) continue;
      if (OrderType() > 1 && OrderType() < 6)
      {
         ticket = OrderTicket();
         numberOfTry = 0;
      
         while (numberOfTry < 3)
         {
            while (!IsTradeAllowed()) Sleep(5000);
                err = 0;

           if (OrderDelete(ticket, Red))
            {
                numberOfTry = 3;
            }
            else
            {
                err = GetLastError();
                Print("err = ", err);
            }
      
            if (err > 0)
            { 
              Print(numberOfTry," #",ticket," Error modifing order: (", err , ") ");
              Sleep(5000); RefreshRates(); numberOfTry++;
            }
         }
      }
   }
}
 
Forexman77:


How to make the minimum and maximum times to be output separately? More precisely, to do it separately is not a problem. The log shows several lines for each time.

What could be the problem? How to make one line output per value. Ideally, you want a time in numbers that can be copied into excel and compared by

and compare it by coincidence.



Here's the script, writes the data to a file. Extremes to the nearest minute for the whole story:

int start() {
 int Handle=FileOpen("ScriptDayExtr",FILE_WRITE|FILE_CSV);
 if(Handle<0) {Print("Ошибка создания файла"); return(0);}
 datetime TimeMax,TimeMin;
 double HistoryMaximum=0;
 double HistoryMinimum=99999999.9;
 int LastH=TimeHour(iTime(Symbol(),PERIOD_M1,0));
 Print("Баров в истории ",iBars(Symbol(),PERIOD_M1)," т.е всего на ",DoubleToStr(iBars(Symbol(),PERIOD_M1)/60.0/24.0,2)," дней");
 for (int i=iBars(Symbol(),PERIOD_M1)-1; i>=0; i--) {
  if(iTime(Symbol(),PERIOD_M1,i)==0) {Print("ERROR");continue;}
  int H=TimeHour(iTime(Symbol(),PERIOD_M1,i));
  if(H<LastH && TimeMax>0){
  FileWrite(Handle," Максимум=",DoubleToStr(HistoryMaximum,Digits)," случился в ",TimeToStr(TimeMax,TIME_DATE|TIME_MINUTES),"             ",
        " Минимум=",DoubleToStr(HistoryMinimum,Digits)," случился в ",TimeToStr(TimeMin,TIME_DATE|TIME_MINUTES));
  HistoryMaximum=0;
  HistoryMinimum=99999999999999.9;
  }
  LastH=H;
  if( iHigh(Symbol(),PERIOD_M1,i)>HistoryMaximum) {HistoryMaximum=iHigh(Symbol(),PERIOD_M1,i);TimeMax=iTime(Symbol(),PERIOD_M1,i);}
  if( iLow(Symbol(),PERIOD_M1,i)<HistoryMinimum)  {HistoryMinimum=iLow (Symbol(),PERIOD_M1,i);TimeMin=iTime(Symbol(),PERIOD_M1,i);}
 }
 FileClose(Handle);
 return(0); 
 }


And to make it in the tester - an indicator has to be written however.