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

 
The most baffling thing is that it happens in this particular section of the story, in others it is normal.
 
DiPach:

If you only use the code in a real or demo account, then this is more convenient. However, in the strategy tester, problems may arise when using it.


For instance, like what? Why I don't have any problems anywhere, but you "may have problems".
 

There's a piece I don't understand.

double Delta =  NormalizeDouble(MathAbs(Bid-PriceOld),Digits);

I get a piece of crap like 5e-005.0 in the printer.

PriceOld value

PriceOld   = NormalizeDouble(Bid,Digits); 
When I add it all up, why does it look like this when I subtract it?
 
001:
The most confusing thing is that it happens on this particular section of the story, on others it's normal.
Read the iLowest() help carefully. What is the number of items to be searched for? And what does it equal in yours.
 
001:

Tried different variants. The result is the same. How this can be so is absolutely unclear. At some moment the iLowest(NULL,0,MODE_LOW,NumberLastBar_beg,NumberLastBar_end); suddenly starts calculating a larger bar range. Please advise who understands, my head is broken. Thanks.


4:08:36 Time+iLowest test started

14:08:36 2004.09.29 00:00 Time+iLowest EURUSD,H1: NumberLastBar_beg= 24 NumberLastBar_end= 0
14:08:36 2004.09.29 00:00 Time+iLowest EURUSD,H1: i=18
14:08:36 2004.09.29 00:00 Time+iLowest EURUSD,H1: time_check_low_day=06:00
14:08:39 2004.09.29 01:00 Time+iLowest EURUSD,H1: NumberLastBar_beg= 25 NumberLastBar_end= 1
14:08:39 2004.09.29 01:00 Time+iLowest EURUSD,H1: i=19
14:08:39 2004.09.29 01:00 Time+iLowest EURUSD,H1: time_check_low_day=06:00
14:08:39 2004.09.29 02:00 Time+iLowest EURUSD,H1: NumberLastBar_beg= 26 NumberLastBar_end= 2
14:08:39 2004.09.29 02:00 Time+iLowest EURUSD,H1: i=20
14:08:39 2004.09.29 02:00 Time+iLowest EURUSD,H1: time_check_low_day=06:00
14:08:40 2004.09.29 03:00 Time+iLowest EURUSD,H1: NumberLastBar_beg= 27 NumberLastBar_end= 3
14:08:40 2004.09.29 03:00 Time+iLowest EURUSD,H1: i=21
14:08:40 2004.09.29 03:00 Time+iLowest EURUSD,H1: time_check_low_day=06:00
14:08:41 2004.09.29 04:00 Time+iLowest EURUSD,H1: NumberLastBar_beg= 28 NumberLastBar_end= 4
14:08:41 2004.09.29 04:00 Time+iLowest EURUSD,H1: i=31

14:08:41 2004.09.29 04:00 Time+iLowest EURUSD,H1: time_check_low_day=21:00

Code:

static int    PrevTime=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   if(Time[0]<=PrevTime) return(0);
   PrevTime=Time[0];
//////////////
 //  CheckForLongetivityClose_Sell();
   double pBid=NormalizeDouble(Bid,Digits),Low_Now=Low[1];
////////////
   int n_beg=1;                                           // индекс дня, в данном случае 1 - вчерашний день
   datetime DayTime_beg=iTime(NULL,PERIOD_D1,n_beg);             // Начало дня "n" в секундах
   int NumberLastBar_beg=iBarShift(NULL,0,DayTime_beg);

   int n_end=0;                                           // индекс дня, в данном случае 1 - вчерашний день
   datetime DayTime_end=iTime(NULL,PERIOD_D1,n_end);             // Начало дня "n" в секундах
   int NumberLastBar_end=iBarShift(NULL,0,DayTime_end);
   Print(" NumberLastBar_beg= ",NumberLastBar_beg," NumberLastBar_end= ",NumberLastBar_end);
//---------------------------------------------------------------------

   datetime Time_Check_Low_Day=Time[iLowest(NULL,0,MODE_LOW,NumberLastBar_beg,NumberLastBar_end)];
   int i=iLowest(NULL,0,MODE_LOW,NumberLastBar_beg,NumberLastBar_end);
   Print(" i=",i);
   string time_check_low_day=TimeToStr(Time_Check_Low_Day,TIME_MINUTES);
/////////////
   Print(" time_check_low_day=",time_check_low_day);

   datetime time_check_verify=StrToTime("H_check_beg:M_check_beg");


   return(0);
  }


Pay attention to these lines.

   datetime Time_Check_Low_Day=Time[iLowest(NULL,0,MODE_LOW,NumberLastBar_beg,NumberLastBar_end)];//iLowest раз
   int i=iLowest(NULL,0,MODE_LOW,NumberLastBar_beg,NumberLastBar_end);                            //iLowest два

These lines should be swapped.

int i=iLowest(NULL,0,MODE_LOW,NumberLastBar_beg,NumberLastBar_end); // исправлять не стал
datetime Time_Check_Low_Day=Time[i];

2. NumberLastBar_beg is the number of yesterday's bar, while this value can be replaced with the number of bars to be searched for.

3. When you paste the code, find the SRC button in the toolbar of the text entry window.

 
AlexeyVik:

Such as which ones? Why is it that I have no problem with it anywhere, but you "may" have a problem with it.

I'm a bit pensive. I don't want to lay out the code of existing indicator, where it can be clearly seen (if not applying a separate condition for the tester). As well as to think, what to prescribe on its basis separate for clarity.

However, if you insist - of course, I will most likely begin to think about what can replace the complicated "stuffing" he has in order to prescribe something else there.
 
Can I use more than 1 timer in my EA? EventSetTimer(5);
 
pu6ka:
Read the iLowest() help carefully. What is the number of elements to search for? And what does it equal?

For some reason I thought it was a range, but it's the number of elements, thanks!
 
AlexeyVik:

Pay attention to these lines

It is better to swap these lines.

2. NumberLastBar_beg is the number of the first bar of yesterday, and you put this value instead of the number of bars you want to search for.


The i variable is here purely for control purposes, for Print. I made a mistake when adjusting the bars. Thanks for the tip!
 
Another question. I can't figure out how to get, with minimal effort, a variable of int type from Time[0] as 00:00. I can't think of anything except for string, StrToTime, and TimeToStr conversions. Thank you!
Reason: