Errors, bugs, questions - page 33

 
Urain:

Thisis a noteworthy suggestion,

Although from the point of view of ordinary logic it is like scratching your left ear with your right hand (but that's not up to you, it's up to the developers),

why do you need to call the data of a non-native instrument?

if you still need to create custom indicators and call them from a required symbol, in general, the conclusion is think head I buy.

The possibility of such a call is necessary, the developers surely couldn't suppose such an approach when writing the indices.

I mean the tool indication in parameters of the user's indicator (and not in iCustom() parameters as it should be in their opinion).


PS

The priority at work with iCustom() appears to have been initially given to mechanical trading that in fact assumes that some moments will be considered and some actions will be performed in the Expert Advisor and only then iCustom() will be called for the custom indicator.

Otherwise all the work and responsibility falls on the programmer implementing the code of the indyke (which may lead to fatal errors and consequences, because too much fancy indyke may lead to braking or crashing of the system as a whole).

 
Urain:

Suggestion worthy of attention,

Although, again, I call the ready indicator for EUR with data on JPY (for example, the history of yen is not enough)

I don't have any data for this length and what will it tell me ??? the same song.

It is much easier to handle errors and bottlenecks in the native tool, and the preliminary check and the final check are done before and after the call in the Expert Advisor or the data requesting indicator.

I assume there is a second way, which is fundamentally wrong from my point of view. According to its logic you need to create one or more functions in the indicator (called from the calculator), calculate everything you need in them and return the result to the calculator.

PS

But here's the thing - you can calculate the number of bars on an arbitrary symbol. But what about other things?

 
Prival:

Bug. Description. ATS always in market (rollover by double lot 0.2).

Test mode all ticks. Everything is normal.

testing mode, by opening prices. the same piece.

For some reason it splits into 2 trades. maybe it's just the way it's displayed, but it's not right. it shouldn't be that way.

Rearrange the opening commands with the closing commands. It should be in this order

- close positions

- modify positions

- open positions

Then your close and open positions will be on the same bar.

 
gpwr:

Rearrange the opening commands with the closing commands. The order should be as follows

- close positions

- modify positions

- open positions

Then your close and open will be on the same bar.

If the market is buy 0.1, I open a sell 0.2. The result of this operation should be 0.1.1 in one transaction, not two.

I think the developers understood what I was saying.

 

I've written this code

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot Label1
#property indicator_label1  "I1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  Red
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Label2
#property indicator_label2  "I2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  Green
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- indicator buffers
double         I1Buffer[];
double         I2Buffer[];
int OnInit()
  {
   SetIndexBuffer(0,I1Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,I2Buffer,INDICATOR_DATA);
   return(0);
  }

int OnCalculate (const int rates_total,      // размер массива price[]
                 const int prev_calculated,  // обработано баров на предыдущем вызове
                 const int begin,            // откуда начинаются значимые данные
                 const double& price[])      // массив для расчета
  {
   string Symbol_1="EURUSD",Symbol_2="GBPUSD";
   if(rates_total<1) return(0);
   double Arr1[],Arr2[];
   int end,rez0,rez1;
   end=MathMin((int)SeriesInfoInteger(Symbol_1,0,SERIES_BARS_COUNT)-1,(int)SeriesInfoInteger(Symbol_2,0,SERIES_BARS_COUNT)-1);
   end=MathMin(end,rates_total-prev_calculated+1);
   rez0=CopyClose(Symbol_1,PERIOD_CURRENT, 0,end, Arr1);
   if(rez0==-1){Print("Ошибка копирования ",Symbol_1," ",GetLastError()); return(0);}
   rez1=CopyClose(Symbol_2,PERIOD_CURRENT, 0,end, Arr2);
   if(rez1==-1){Print("Ошибка копирования ",Symbol_2," ",GetLastError()); return(0);}
   if(rez1!=rez0){Print("Ошибка Синхронизации"); return(0);}
  
   ArraySetAsSeries(Arr1,true);
   ArraySetAsSeries(Arr2,true);
     
   int li=rates_total-1;  
   for(int i=0;i<end;i++)
     {      
      I1Buffer[li]=Arr1[i]+0.26;
      I2Buffer[li]=Arr2[i];
      li--;
     }
   return(rates_total);
  }

It seems to work fine, but whether it takes everything into account I don't know.
If it does, here is a variant for you.
If not correct, please correct it.

 

Now I have a question.

Why is the indicator called from the Expert Advisor, the value does not coincide with the indicator.

I.e. indicator has 1.5123 and EA gets 1.5117

I tried to use it because I don't know how to read it and I don't want to miss it.

static int Handle;
int bars;
void OnInit()
  {
   Handle=iCustom(NULL,0,"proverka");
  }

void OnTick()
  {
   if(bars==Bars(_Symbol,_Period))return;
   bars=Bars(_Symbol,_Period);
   double buf1[],buf2[];    
   if(CopyBuffer(Handle,0,0,2,buf1)<0 || CopyBuffer(Handle,1,0,2,buf2)<0)Alert("Ошибка копирования значений индикаторных буферов ",GetLastError(),"!!");
   Print("Время "+TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES),"   буф1-",buf1[0],"   буф2-",buf2[0]);
  }

and image

And the first buffer, the instrument on which it is running, coincides.

Files:
prover.mq5  1 kb
proverka.mq5  2 kb
 
ddd06:

Now I have a question.

Why is the indicator called from the Expert Advisor, the value does not coincide with the indicator.

I.e. indicator has 1.5123 and EA gets 1.5117

Here is the code of EA, besides it is duplicated in the attachment.

And you look at the previous value of the indicator. I suspect it is exactly 1.5117. Take the current (last) value by index 1. Or assign arrays SetAsSeries(bufX,true)
 
stringo:
And you look at the previous indicator value.
1.512380 - current 1.512310 - previous
 
ddd06:

I wrote this code

It seems to work fine, but whether it takes into account all I don't know.
If it does, here's a variant for you.
If not correct, please correct it.

Yes, my reworked version also has a check for array length, but I got lost in the directions of the series, as usual,

and it turned out that the drawing went on, but because the length of the array is less than the length of the chart, the drawing went from the end to the middle (or thereabouts),

That's why I had an impression that there was no rendering.

In general, I suspect that there will be confusion in this place for a long time,

because the same problem was with visitors of mql4.com and now they are downloading here.

 
Urain:

That's right.

That's great. I think the code is simple and local, so you can use it as a basis.

Question about EA - should I write to Service Desk?

Общайтесь с разработчиками через Сервисдеск!
Общайтесь с разработчиками через Сервисдеск!
  • www.mql5.com
Ваше сообщение сразу станет доступно нашим отделам тестирования, технической поддержки и разработчикам торговой платформы.