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

 
Veterros:
Thank you very much! Checked through Comment, it works! I must have misunderstood the information about using multiple TFs in the tester.
Not at all, always check with Comment in the tester in VisualMode and on demo! I test on M1 with open bars, the Expert Advisor can use any TF, but it is desirable to have all charts open, starting from M1 up to and including the one the data are taken from. I have it up to D1, because I use daily pivot lines, resistances and supports.
 

Hello! The attached indicator draws fractals. It draws them directly on the high/low bars and therefore I cannot see the high/low bars. How can I adjust the distance between the fractal and the bar? I need the fractal to be slightly above/below the bar.

If it's not complicated, it may be easy to do it directly in this indicator...

Help, please!

Files:
 
Serhios:

Hello! The attached indicator draws fractals. It draws them directly on the high/low bars and therefore I cannot see the high/low bars. How can I adjust the distance between the fractal and the bar? I need the fractal to be slightly above/below the bar.

If it's not complicated, maybe it won't be a problem to do it directly in this indicator...

Help, please!

Obviously, we should add some value for the upper fractal and subtract the same value for the lower fractal, then the fractals will be shifted vertically. The ATR value, as in the trailer, would be suitable, for example.
Files:
 
evillive:
Obviously, we need to add some value for the top fractal and subtract the same value for the bottom fractal, then the fractals will be shifted vertically. The ATR value, as in the trailer, would be suitable, for example.

Thanks. But, is it really necessary to use the value of another indicator in solving this problem? There is the value of the bar at which the fractal was drawn. Is there no function that moves the fractal vertically with respect to high/low bar value?
 
Serhios:

Thank you. But, is it really necessary to use the value of another indicator in solving this problem? After all, there is the value of the bar on which the fractal was drawn. Isn't there a function that will shift the fractal vertically with respect to high/low bar value?

You can take any value in pips (integer) instead of indicator value, multiplied by _Point, it will be constant offset by given number of pips. It is easier with indicator, there is no need to adjust distance.

Example for the upper fractal:

Ext1[i+center] = cur + 30*_Point;
 
evillive:

You can take any value in pips (integer) instead of indicator value, multiplied by _Point, it will be constant offset by given number of pips. It is easier with indicator, there is no need to adjust distance.

Example for the upper fractal:

It's better to scale, otherwise icons of fractals will creep outside the boundaries of the screen. You can do this:

// Определение LastBar по расположению StopLine на графике
bool fNewStopLine(){
   bool New;
   int StopBar, Error;
   double Shift;
   datetime StopLine;
   if( ObjectFind("StopLine")==0 ){                // Есть стоп-линия
      StopLine=ObjectGet("StopLine",OBJPROP_TIME1);// Время стоп-линии
      StopBar=iBarShift(NULL,0,StopLine);          // Бар стоп-линии
      LastBar=StopBar+1;                           // Бар окончания построения
      if( StopBar<=БарОкончания ){                 //    правее или на последнем баре
         LastBar=БарОкончания;                     // Перенести на нулевой бар
         StopBar=LastBar-1;
         StopLine=Time[StopBar];
         if( !ObjectMove("StopLine",0,StopLine,0) ){
            if( !РежимОтладки ) PlaySound("alert.wav");
            Print("***   StopLine - объект не перемещен, ошибка "+GetLastError());
      }  }
      if( StopLine!=OldStopLine ){                 // Новая стоп-линия
         ReInit();                                 // Повторная инициализация
         ClearScreen();                            // Очистить экран
         Shift=0.01*(WindowPriceMax()-WindowPriceMin())*СдвигИндикатораТиков;
         Error=fArrow("TickIndicator","",0,StopBar // Сформировать индикатор тика
                     ,WindowPriceMin()+Shift,0,0,0,0
                     ,ЗнакИндикатораТиков,ЦветИндикатораТиков,РазмерИндикатораТиков);
         OldStopLine=StopLine;                     // Стоп-линия обработана
         New=true;                                 // Выполнить построение заново
      }
      else{                                        // Нет новой стоп-линии
         New=false;                                // Построение заново не выполнять
   }  }
   else{                                           // Нет стоп-линии
      New=false;                                   // Построение заново не выполнять
      Error=fObjectDelete("TickIndicator");        // Удалить индикатор тика
   }
   return(New);
}
а можно просто использовать значки фракталов, не закрывающие экстремумы баров, вот так: 

 

I still don't understand the priorities and order of operations , e.g,

*
/
%

Multiplication
Division
Modulo division

From left to right


What is the value of a=b/s*s, a=b or a=b/s^2?

 
evillive:


What will the expression a=b/c*s be equal to, a=b or a=b/c^2?

Checked with the script:

   double a;
   double b=10.0;
   double c=4.0; 
   a=b/c*c;
   Print("a=",a);

Print in log: a=10.0

PS: and if you do this: a=c*c/b; then the print will be a=1.6

 
tuner:

Checked with the script:

Print in log: a=10.0

PS: and if you do this: a=c*c/b; then print will be a=1.6

Well, yes, I checked it myself, but in the handbook about priorities they say that multiplication takes precedence over division, so multiplication should be done first, if brackets don't specify the order, no?


In practice, division comes first, then multiplication...

 

Hello! Help me out here. I am writing my first EA in MQL4.

My Expert Advisor opens a position but does not close it. It does not show any errors in the log.

void OnTick()
  {RefreshRates();
  ma1=iMA(_Symbol,TimeFrame,Period_MA1,Shift_MA1,metod_ma1,PRICE_CLOSE,0);
ma2=iMA(_Symbol,TimeFrame,Period_MA2,Shift_MA2,metod_ma2,PRICE_CLOSE,0);


if (ma1<ma2)
{
SellPositionClose();
BuyPositionOpen();
}

if (ma1>ma2)
{
BuyPositionClose();
SellPositionOpen();
}
}
 

     
void BuyPositionOpen()  // покупка
{int res=0;
RefreshRates();
if (OrdersTotal()==0)
res=OrderSend(_Symbol,OP_BUY,Lots,Ask,3,0,0,"",Magic,0,Blue);
if (res<0) Print("OrderClose111111 error ",GetLastError());
}

void     SellPositionOpen() // продажа
{int res=0;
RefreshRates();
if (OrdersTotal()==0)
res=OrderSend(_Symbol,OP_SELL,Lots,Bid,3,0,0,"",Magic,0,Red);
if (res<0) Print("OrderClose111111 error ",GetLastError());
}

void BuyPositionClose() // закрытие длинной позиции
{RefreshRates();
if ((OrdersTotal()!=0) && (OrderMagicNumber()==Magic))
{
if (!OrderSelect(0,SELECT_BY_POS,MODE_TRADES)) Print("OrderClose error ",GetLastError());

 if(OrderType()==OP_BUY)
           
            if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
               Print("OrderClose error ",GetLastError());
               }
               }
               
void SellPositionClose()  // закрытие короткой позиции
{RefreshRates();
if (OrdersTotal()!=0 && OrderMagicNumber()==Magic)
{
if (!OrderSelect(0,SELECT_BY_POS,MODE_TRADES)) Print("OrderClose error ",GetLastError());
    
     if(OrderType()==OP_SELL)
                
            if(!OrderClose(OrderTicket(),OrderLots(),Ask,100,White))
               Print("OrderClose error ",GetLastError());
               
               }
               }