[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 103

 
Reshetov:

No, she doesn't owe anyone anything. There is a difference between a demo-real and a tester. For example, the tester will never show an error when opening orders, if all OrderSend() parameters are correct. But a trade server, on the contrary, it will.

This is why we should modify the programs after the tester and then run them on the demo, so that they can adequately handle exceptional situations, which do not occur in the tester.

Thanks!!!
This is very useful information for me))
 
Reshetov:
Use Time[x] bar time.


It won't work here, because in the next line on the same bar this first formed figure will be initiated as the second one too... And I need to separate them... separate

to then compare the lows - if long and the highs - if short...

......
if (AO3 < 0 && AO3 > AO2 && AO2<0 && AO2 < AO1 && AO1 < 0 && fl1==false && fl2==false) {a1 = AO2; fl1=true;Time_Figure1=TimeCurrent(); Print ("образование первого пика",DoubleToStr(a1, 6),"Время: ",Time_Figure1);}// определение наличия 1-го пика, флаг установлен
 Print ("Образование первого пика",DoubleToStr(a1, 6),"Время1: ",Time_Figure1);
 sleep (2000);
 if (AO3<0 && AO3>AO2 && AO2<0 && AO2<AO1 && AO1<0 && fl1==true && fl2==false && TimeCurrent() > Time_Figure1)  // определение наличия 2-го пика, флаги установлены
      { 
        a11 = AO2; fl1=true; fl2=true; Print ("Образование второго пика", DoubleToStr (a11,6), "Время2: ",Time_Figure2);
.....

 
robot:

If it's not difficult to write a template, I'm not thinking straight yet)

Thank you for your consideration.
I suggest you look at examples of trading coding, for example, here
 
Roman.:


It won't work here, because in the next line on the same bar this first formed figure will be initiated as the second one too... And I need to separate them... separate

for subsequent comparison of lows - if long and highs - if short...

Not like this. If you have the AO signal bar first, then look from it and look for the rest deep into history. When you open a position, remember the time of the bar opening and do not open on it again. As soon as the next AO bar is formed, start looking for a pattern again.
 
artmedia70:
Not so. If you have the first signal bar of AO, then from it and look for the others deep into the history. When you open a position, remember the time of the bar opening and do not open it again. As soon as the next AO bar is formed, start looking for a pattern again.


Can you elaborate - I don't need to search deep into the history...

It is enough for me to determine in the present if a peak came - that it is Fig.1, and if after some bars as in the figure another peak came, then to compare them and make a decision...

The question is that both spikes of the first and the second figure are the same and I cannot (even using flags to distinguish one figure from another)... I am dull what-what...

P.S. The spikes don't necessarily follow one after the other, they may be through several equal bars, etc. They may be different - the main thing is that the principle of their construction is the same.

The main thing is to separate one from the other for further comparison.

 
Reshetov:
Use Time[x] bar time.

In general, it is possible to interrupt the EA at a certain point in the code before the next bar is formed after some commands are executed.
 
Roman.:

In general, it is possible to interrupt the EA in a certain place in the code before the next bar is formed after some commands are executed.
Yes, there is. You store the current value of Time[0] in a static variable and compare it with every new tick. If it has not changed, we return(0). If it has changed, we are dealing with a new bar. Remember the time of the new bar, i.e. Time[0] and start your own calculations.
 

eddy:

for(k=0; k<KPeriod; k++)           // перебрать KPeriod баров
if(Low[k]<minimum) minimum=Low[k]; // найти минимум

how to properly replace this with iLowest function?

minimum=Low[iLowest (NULL, 0, MODE_LOW, KPeriod, 0)] - is this correct?

I was told so. thank you all for mutually ignoring a simple question)
 
Reshetov:
Yes, it does. You store the current value of Time[0] in a static variable and compare with every new tick. If it hasn't changed, you exit with return(0). If it has changed, we are dealing with a new bar. Remember the time of the new bar, i.e. Time[0] and start your own calculations.


I have known it a long time ago... :-)) More from a textbook... Thank you...

I'm comparing now, I think I'm on the right track, but so far it's not working as it should...

double AO1 =  iAO(Symbol(), signal_period, 1);
 double AO2 =  iAO(Symbol(), signal_period, 2);
 double AO3 =  iAO(Symbol(), signal_period, 3);
 
 
 //  Расчет переменных для доливки 2-а пика
  
 if (AO3 < 0 && AO3 > AO2 && AO2<0 && AO2 < AO1 && AO1 < 0 && fl1==false && fl2==false) {a1 = AO2; fl1=true;Time_Figure1=Time[0]; Print ("Oбразование первого пика",DoubleToStr(a1, 6),"Время: ",Time_Figure1);}// определение наличия 1-го пика, флаг установлен
 Print ("Образование первого пика",DoubleToStr(a1, 6),"Время1: ",Time_Figure1);
 if (Time_Figure1<Time[0] && Time_Figure1!=0)    // условие наличия первого пика...
   {
    if (AO3<0 && AO3>AO2 && AO2<0 && AO2<AO1 && AO1<0 && fl1==true && fl2==false )  // определение наличия 2-го пика, флаги установлены
      { 
        a11 = AO2; fl1=true; fl2=true; Time_Figure2=Time[0]; Print ("Образование второго пика", DoubleToStr (a11,6), "Время2: ",Time_Figure2);
        if (a1<a11 && High [0] > High [1]) 
           { signal_buy = true; a1=a11; fl1=true;fl2=false; Time_Figure1=Time[0];}   //  активируем бай и устанавливаем сигнал на бай и записываем параметры как первого пика  
        else { a1=a11; fl1=true;fl2=false;Time_Figure1=Time[0];}                     //  просто запоминаем новый минимум - "первый" сигнал   
      }                                                       
   }
 
 if (AO2>0 || High [0] < High [1]) {fl1=false; fl2=false; Time_Figure1=0;}// если какой - либо столбец гистограммы  пересекает 0-ю линию между сигналами 2-а пика
                                                               // то сигнал считается недействительным. Cбрасываем флаги 1-го и 2-го пика вниз,
 if (Mas_Tip[0]!=0 && signal_buy == true )  return(10);        // при доливке и сигнале к покупке открываемся с рынка 
 signal_buy = false;                                           // сбрасываем сигнал к покупке
You have correctly suggested me the use of Time[x] - trying to implement...
 
Guys really need a script to add days off to the chart in MT4, where to find it
Reason: