A question for MQL connoisseurs - page 8

 

Thank you.

 

Good afternoon, all.

Please advise. The indicator shows the price lines of the instruments and

There is a text comment on the right - their names and position sizes.

Everything is working fine. As long as I do not put the indicator on the chart of instruments with 5-digit quotes.

The price lines are drawn. But the comment on the right disappears altogether. Or, zeros are displayed instead of position sizes.

The log shows ZERO DIVIDY (see the Alpari chart)

- on EURUSD and GBPUSD - instead of the size zeros are displayed...

I think this has to do with the calculation of position sizes:

double vol1=1, vol2, vol3, k1;

  k1=MarketInfo(Symbol_1, MODE_TICKVALUE)*iOpen(Symbol_1,0,0)/
     MarketInfo(Symbol_1, MODE_TICKSIZE);

  vol2=k1/(MarketInfo(Symbol_2, MODE_TICKVALUE)*iOpen(Symbol_2,0,0)/
           MarketInfo(Symbol_2, MODE_TICKSIZE))*vol1;

  vol3=k1/(MarketInfo(Symbol_3, MODE_TICKVALUE)*iOpen(Symbol_3,0,0)/
           MarketInfo(Symbol_3, MODE_TICKSIZE))*vol1;

    // пишем комментарий в окне индикатора с правой стороны: 
 object("Symbol1", DoubleToStr(N1,0)+"*"+Symbol_1+" -"+DoubleToStr(vol1,2), 10, indicator_color1, 5);
 object("Symbol2", DoubleToStr(N2,0)+"*"+Symbol_2+" -"+DoubleToStr(vol2,2), 10, indicator_color2, 18);
 object("Symbol3", DoubleToStr(N3,0)+"*"+Symbol_3+" -"+DoubleToStr(vol3,2), 10, indicator_color3, 31);
 object("SymbolS", "AVERAGE", 10, indicator_color4, 44);   
           

Ratio k1=MarketInfo(Symbol_1, MODE_TICKVALUE)..../MarketInfo(Symbol_1, MODE_TICKSIZE)

gives "division by zero" at 5 digits.

Please advise how to fix it ?

 

Please tell me if there is a script or indicator that shows transactions made earlier on the history, such as from so-and-so to so-and-so date. Very. useful thing in my opinion

Thank you,

Yuri

 
leonid553:

Good afternoon, all.

Please tell me how to fix this ?


In simple words, try to replace MODE_TICKSIZE with MODE_POINT. But actually, you need to rewrite the code to account for null MarketInfo()
 
tyn:

Please tell me if there is a script or indicator that shows transactions made earlier on the history, such as from so-and-so to so-and-so date. Ochen. useful thing in my opinion

I think it would be very useful,

Yuri

https://www.mql5.com/en/code - script. You can set the time frame in the history of your terminal.

VisualOrders.mq4 - indicator

Files:
 

Good afternoon.

In mt4 EXNESS my "multicurrency" indicators, for some reason, work only when the Internet is connected (unlike mt4 of other brokerage companies).

I've got an error when I don't use it and I've got a negative feedback. The log gives out a "zerodive".

When I connect to the Internet, often I have to click the TF first to get the indices lines to appear.

Could you please tell me what the problem is and how to fix it?

When the internet is switched off:

When connected:

 
leonid553:

Good afternoon.

In mt4 EXNESS my "multicurrency" indicators, for some reason, work only when the Internet is connected (unlike mt4 of other brokerage companies).

I've got a good working relationship with my forex indicators. The log gives out a "zerodive".

When I connect to the internet, often I have to click the TF first to get the indices lines to appear.

Can you tell me please what is the problem and how to fix it?

When the internet is switched off:

When connected:


It's a normal thing. It happens a lot. And it can't always be dealt with. Although dividing by zero can be fixed. The problem is the lack of a market environment more often than not.
 

I don't quite get it, Victor.

Is this a "normal thing"? It's clearly a glitch!

I don't understand the term - "no market environment".

If we fix the division to zero - will the price lines appear? I don't think so.

The comment in the right corner of the indicator window is displayed normally. I.e., functions ObjectCreate, etc. are working normally.

Similarly, mathematical calculations the numbers of which are set in the comment work normally.

Only price lines of the indicator remain. There is nothing else there.

Price lines are set in buffers. Each price line is only a difference between two MA:

int start() {
     int limit;  int counted_bars=IndicatorCounted();
  //---- проверка на возможные ошибки
     if(counted_bars<0) return(-1);
  //---- последний посчитанный бар будет пересчитан
     if(counted_bars>0) counted_bars-=10;      limit=Bars-counted_bars;
  //---- основной цикл
 for(int i=0; i<limit; i++)       {
 
   Symbol1[i]= N1*
     (iMA(Symbol_1,Period(),MA_fast,0,MA_Mode,MA_Price,iBarShift(Symbol_1,0,Time[i],false))-
     iMA(Symbol_1,Period(),MA_per,0,MA_Mode,MA_Price,iBarShift(Symbol_1,0,Time[i],false)))  ;
  .... ....

So this is the part that gives the "zero divide"! But there is no division here at all, much less division by zero!

Hence, the error in this case is returned by the server (or platform) from the background? Or maybe the developers of MT4 have not considered such a glitch and have set "the zero-divided" return that does not exactly correspond to the essence of such an error.

And why does the indicator work fine in MT4? Why does the indicator work normally?

How can similar platforms be different so that this simple code works differently in them?

 

Division by zero can be handled, but you also need the indicator to work correctly. This is more difficult.

 

What could theoretically be wrong with this simple code (for 4 lines)):

int start() {
     int limit;  int counted_bars=IndicatorCounted();
  //---- проверка на возможные ошибки
     if(counted_bars<0) return(-1);
  //---- последний посчитанный бар будет пересчитан
     if(counted_bars>0) counted_bars-=10;
     limit=Bars-counted_bars;

  //---- основной цикл
 for(int i=0; i<limit; i++)       {
   //РИСУЕМ ЛИНИИ СИМВОЛОВ, ЕСЛИ ИМЕЮТСЯ БАРЫ

   Symbol1[i]= N1*
     (iMA(Symbol_1,Period(),MA_fast,0,MA_Mode,MA_Price,iBarShift(Symbol_1,0,Time[i],false))-
     iMA(Symbol_1,Period(),MA_per,0,MA_Mode,MA_Price,iBarShift(Symbol_1,0,Time[i],false)))  ;
   Symbol2[i]= N2*
     (iMA(Symbol_2,Period(),MA_fast,0,MA_Mode,MA_Price,iBarShift(Symbol_2,0,Time[i],false))-
     iMA(Symbol_2,Period(),MA_per,0,MA_Mode,MA_Price,iBarShift(Symbol_2,0,Time[i],false)))  ;
   Symbol3[i]= N3*
     (iMA(Symbol_3,Period(),MA_fast,0,MA_Mode,MA_Price,iBarShift(Symbol_3,0,Time[i],false))-
     iMA(Symbol_3,Period(),MA_per,0,MA_Mode,MA_Price,iBarShift(Symbol_3,0,Time[i],false)))  ; 
   Symbol4[i]= N4*
     (iMA(Symbol_4,Period(),MA_fast,0,MA_Mode,MA_Price,iBarShift(Symbol_4,0,Time[i],false))-
     iMA(Symbol_4,Period(),MA_per,0,MA_Mode,MA_Price,iBarShift(Symbol_4,0,Time[i],false)))  ;
    
      
      
   }
   return (0);
} // конец функции СТАРТ