[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 553

 
Svinozavr >>:
Вам удобней это будет отдельным индикатором сделать. Сначала, в цикле пересчета заполняете инд. буфер значениями индикатора, а затем по этим значениям считаете сигнальную МА.

Вот пример расчета МА по RSI (ф-я старт):

Oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh-oh! I didn't see it right away! Just what the doctor ordered. Thank you. You've got endless profits! :):):)
 

artmedia70, We will go through all orders and sum up their profits. If the resulting profit is higher than zero or higher than a predefined value, we will close all positions.

double SummProfit(){
  double Profit=0;
 for(int i=OrdersTotal()-1;i>=0;i--){
   if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
     Print("Ошибка № ",GetLastError()," при выборе ордера № ",i);
   }
   else {
     Profit=Profit+OrderProfit();
  }
 }
  return(Profit);
}

Try the code to close all orders yourself.

Hint: For a loop in which all orders will be closed, you need to reverse the direction of the order enumeration - exactly as I did in the above code. Namely, we should go from the last order to the first one. If we change the direction, not all orders will be closed in the loop. For example, the order placed first in the list will be closed and, as a result, another one will replace it. And since the counter of the loop is incremented by one, another order from this line will be skipped.

 

I have a question - does the MT4 tester take swaps into account? There is no mention of swaps in the tester log file.

 
chief2000 >>:

Возник вопрос - учитывает ли тестер МТ4 свопы? В лог-файле тестера нет ни единого упоминания о свопах.

OrderSwap()

 
sergeev >>:

OrderSwap()

There is currently no way to add this command for testing

- can it be considered as a confirmation that MT4 takes swaps into account during testing and optimisation?

 
I think so, as it calculates and returns values. and therefore (99% probability :) is accounted for in the balance sheet
 
sergeev >>:
думаю да, так как она вычисляется и возвращает значения. а следовательно (вероятность 99% :) учитывается на балансе

Thank you!

 

How to correctly draw a circle with the radius of the last ZigZag break.

The radius calculation will be like this, but I don't know how to draw a circle in MT.

 double y3, y2, y1, zz;// экстремумы Зиг-Зага
 int    x3, x2, x1, sh;// номера баров
  y3=0;y2=0;y1=0;                                             // экстремумы Зиг-Зага
  sh=ShiftBars;                                               // номера баров
  // Берём три экстремума Зиг-Зага
  while (y3==0) {
    zz=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, sh);
    if (zz!=0 && zz!=EMPTY_VALUE) {
      if      (y1==0) { x1=sh; y1=zz; }
      else if (y2==0) { x2=sh; y2=zz; }
      else if (y3==0) { x3=sh; y3=zz; }
    }
    sh++;
  }
  double R=MathSqrt(MathPow(MathAbs(y1-y2),2)+MathPow((x2-x1),2));// радиус последнего перелома
 
sasha2x >>:

Расчет радиуса будет такой,а как сделать чтобы на рисовался круг в МТ не знаю.


https://www.mql5.com/ru/articles/1503/page2
 

How can I make indicator lines instead of objects?

This seems to be the formula where (x0,y0)is the centre of the radius.

In the Cartesian coordinate system the circle is not the graph of a function, but it can be described as the union of the graphs of the following two functions:

Reason: