[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 175

 
alsu:

No, from the one the variable i had before the cycle. Write

is identical to

   int cnt,i;
for (cnt = 0, i = index + g_center - 1; i >= 0 && cnt < g_center; i--) 

Now I get it. Thank you. I was looking... there was no reference point. Now it's 0.


Hmm. Well, for example, index is passed as 1. Let's look at this piece of code:

 int cnt = 0, i = index + g_center - 1;
   for (; i >= 0 && cnt < g_center; i--)           // Справа от центрального бара должно
   {                                               // ..быть g_center-1 баров с большим..
      if (centerLow >= Low[i])                     // ..минимумом. Не позволяется..
         return (false);                           // ..наличие баров с меньшим или..
      cnt++;                                       // .. равным минимумом
   }
   

immediately on arrival it will be:cnt = 0, i = index + g_center - 1 = 1(index value) +2(g_centervalue) - 1 = 2

But according to the loop's condition, it will continue until i equals 0. How will this happen?

The condition says that if i has a value from 2(if index = 1), to i >= 0 andcnt has a value from 0, tocnt < g_center, then the nested conditions are fulfilled.

It turns out that if the variable here is 1, then we will only have 1 iteration in the loop, right?

 
alsu:

Explain the concept of "limited to 0 bar"
In other words I need to draw a line (not a ray) through 2 fractals but it must end on 0 bar
 
beginner:
In other words I need to draw a line (not a ray) through 2 fractals, but it should end on 0 bar


The algorithm is as follows:

1. Let the fractal coordinates be (i1; p1) and (i2; p2), where i1<i2 (i.e. the 1st fractal is closer to 0 bar than the 2nd)

2. Equation of the line passing through these fractals p = (p1-p2)/(i1-i2) * i + (p2*i1 - p1*i2)/(i1-i2)

3. Hence, we need to draw a segment with the following end coordinates: (0; (p2*i1 - p1*i2)/(i1-i2)) and (i2;p2)

4. ObjectCreate(...)

5. ???

6. Profit!!!

 
Vinin:

It should work on the first tick of the new day.

Thanks for the response! True, it never worked until I inserted at the beginning of the indicator start

if(Hour() == 0 && Minute() == 0 && Seconds() == 0) { DeleteObject() etc.

}

if(Hour() >= 0 && Minute() >= 0 && Seconds() >= 1) { indicator code ...

Recently it doesn't work with this one either! I don't know what to do. What can you advise? Thank you!

Just managed to write it now, I'm working for a living on Saturday.

 
hoz:


Yes Boris, that's very good, by the way! Thank you very much. That's what I wanted. I twisted it... I twisted it... I didn't get it right. I haven't had much experience yet, and my brain isn't thinking like a pro. It's a bit of a dead end, isn't it? :(

I didn't want to ask right away, but I had to. Because I couldn't make the cut myself.

I'm glad it was of use to you! I myself, like you, started 2 years ago, but since childhood I'm accustomed to always come to everything on their own, because knowledge from tips can not form a system. And I ask only when absolutely necessary, when I have already done everything, looked everywhere and did not get it. Many newcomers here want to quickly weld and pump dough. Experience will teach them. I've told you before that it's better to make something simple, which is clear to you, than something complicated, which you don't understand, and it's better to avoid such situations until you get to the bottom of it. The code can be done in different ways, but the logic must be as clear as two to you. That's why I avoid using what I don't understand yet. The code is your tool, which you should know and master perfectly, so that you can easily tweak it in time. I wish you success!
 
hoz:

Now I get it. Thank you. I was looking... there was no point of reference. Now it's 0.


Hmm. Well, for example, index is passed as 1. Let's look at this piece of code:

immediately on arrival it will be:cnt = 0, i = index + g_center - 1 = 1(index value) +2(g_centervalue) - 1 = 2

But according to the loop's condition, it will continue until i equals 0. How will this happen?

The condition says that if i has a value from 2(if index = 1), to i >= 0 andcnt has a value from 0, tocnt < g_center, then the nested conditions are fulfilled.

It turns out that if the variable here is 1, we will have only 1 iteration in the loop, right?


The loop terminates when the condition written in the second place of for() operator is no longer satisfied, i.e. in this case, when i becomes less than 0, or when cnt becomes greater than or equal to g_center. Both variables have initial values assigned before the loop and change during its execution: the variable i as a result of i-- (the third part of the for statement, it is executed every time the loop reaches the closing bracket }) and the variable cnt as a result of cnt++.
 

Hi.

Trying to export to html my trade from my demo account. (Alpari, latest build). I press save as report, a folder selection window opens, I press save, nothing happens. Is it the same for demo accounts? One more thing, my MT4 is installed on my desktop. Does it matter?

 
borilunad:
Who knows, is it possible by making Hour(), Minute() and Seconds() global variables, to control the change of DailyPivotPoints indicator to the new PP levels and other lines from the EA at midnight (0.00)? I used to do it directly in the indicator with Hour(), Minute(), Seconds(), and it worked without having to compile every night. But recently it stopped changing itself, maybe from changing the bild? Thanks!


:) Why not implement this as a new bar function? You need it to be recalculated once a day, i.e. starting from 0.00 o'clock. So we do it simply. In the start of course:

if (lastBarTime == время с ТФ Д1)
    return(0);
// что-то тут ещё
// что-то тут ещё
// что-то тут ещё
if (lastBarTime != время с ТФ Д1)
{
    пересчитывает уровни пивотов...
    lastBarTime = время с ТФ Д1;
}
I think this is the most correct way, even though it's primitive!
 
alsu:

The loop ends when the condition written in the second place of for() operator is no longer satisfied, i.e. in this case, when i becomes less than 0 or when cnt becomes greater than or equal to g_center.


But it's not either, it's AND. The && sign is there, too.

I understand all that. But the point here is this:

bool IsUpFractal(int index)
{
   double centerHigh = High[index + g_center];     // За точку отсчета берется средний..
                                                   // ..бар на участке из i_fractalPeriod
                                                   // ..баров
// - 1 - == Поиск максимумов справа от центрального бара ================================
   int cnt = 0, i = index + g_center - 1;
   for (; i >= 0 && cnt < g_center; i--)           // Справа от центрального бара должно
   {                                               // ..быть g_center-1 баров с низшим..
      if (centerHigh <= High[i])                   // ..максимумом. Не позволяется..
         return (false);                           // ..наличие баров с большим или..
      cnt++;                                       // ..равным максимумом.
   }
   
   if (i < 0)                                      // g_center-1 низших максимумов не..
      return (false);                              // ..найдено. Фрактала нет
// - 1 - == Окончание блока =============================================================

Variableindex in general by code has value Bar - IndicatorCounted()

I.e. it is 1 on the current bar and 2 on the new one.

It enters the IsUpFractal() function with the value either 1 or 1 if the bar is not yet new, right?

So, the i variable will have a fixed value since the input parameter index is also fixed. So the loop will always break after the first iteration. What's the point of the loop then?

 

Can you please tell me why it's not showing...

double IN[111];
double PERI=33;
double KRIT;
int z;      
ArraySetAsSeries(IN,true);

   for(z=0; z<=PERI; z++)  {
IN[z]=     iClose(Symbol1.Name,0,iBarShift(Symbol1.Name,0,Time[z],false)); }

   for(z=0; z<=PERI; z++)  {
KRIT=IN[z]-iMAOnArray(IN,0,PERI,0,MODE_SMA,iBarShift(IN,0,Time[z],false)); }

Print(KRIT);
return;
Reason: