Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1892

 

More advice, please.

I have transferred the EA to mt5, everything seems to be working. I have written a custom indicator on mt4 to check the correctness of the execution, I am also moving it to mt5.

I have adapted the indicator, it seems it works too, but not very well.

1) it does not work deleting objects from the chart when uninstalling. I think there is no place to make a mistake.

int OnInit()

{

ObjectCreate(0, "GBP_S0",OBJ_LABEL,0,0,0);

return(INIT_SUCCEEDED);

}

void OnDeinit(const int reason);

{

ObjectDelete(0, "GBP_S0");

}

2)

If we do it this way:

ExtGBPBuffer[i]=GBPTP;

ObjectSetString(0, "GBP_S101",OBJPROP_TEXT,ExtGBPBuffer[i]);

Then the value GBP_S101 is exactly what we're looking for. But the line is zero. How can this be? I.e. the line is drawn and everything is fine, colour, width, everything except values.


Even if I do it this wayExtGBPBuffer[i]=2; the line is still 0

 
Sergey Dymov #:

1) Deleting objects from the graph when uninstalling doesn't work. There seems to be nowhere to go wrong.

It works

 
for(int cycle=1; cycle<=6; cycle++) { int period = per+(CountBuy()+CountSell()); vgran = iCustom(NULL,TF,"Канал_1",period,1,0);      }
A tip. I add an indicator via iCustom and loop through this indicator, changing 1 instance parameter-period. As a result, I choose some variant and work with it. I take only the last bar. But when I stop my Expert Advisor, I notice that it displays a dozen of indicators with different parameters, and for the entire length of the history. When I modify an indicator into a histogram (a separate window), respectively, ten histogram windows appear. How to remove (not to display lines), and not to use the whole indicator during the cycle enumeration, but only the last value.
 
Aleksandr Kononov when I stop my Expert Advisor, I notice that I see a dozen of indicators with different parameters, and for the whole length of history. When I modify an indicator into a histogram (a separate window), respectively, ten histogram windows appear. How to remove (not to display lines), and not to use the whole indicator during the cycle enumeration, but only the last value.
   HideTestIndicators(true); 
   MaCurrent=iMA(NULL,0,56,0,MODE_EMA,PRICE_CLOSE,0); 
   MaPrevious=iMA(NULL,0,56,0,MODE_EMA,PRICE_CLOSE,1); 
   HideTestIndicators(false);
 

Guys, advise on mql4 custom indicator built on MA based on opening prices, it doesn't change its readings with new ticks coming, that's why it is based on opening prices.

On mql5 the adapted indicator changes its readings in the transition zone with every tick... Also by opening prices, even like this


copy=CopyBuffer(MA2EURJPY,0,1,CountBars,MA2EURJPY_TF);

if(copy<0)

Print("Copy failed MA2EURJPY_MAS");


to take a second reading, but it still ticks back and forth


Andrey Sokolov #:

It works

I have a feeling that the language is glitchy. When I edit an unrelated fragment in mql5, everything stops working...



 
Sergey Dymov #:

I have a feeling that the language is glitchy as hell. When I edit an unrelated section in mql5, everything stops working... I've had such situations too, but every time I find out "it wasn't the babina", so it's not the babina, so it's not the mql4.

I also had similar situations, but every time it turned out that "it wasn't the babina", so...

 

Can you give me a hint?

In mql4 there was an indicator based on MA on the opening price, it allowed to avoid re-rendering on the current bar. through int start() it worked fine. It showed everything clearly.

In mql5, the same indicator doesn't work through int start, it works through int OnCalculate. It keeps re-calculating and re-drawing, for a second the image disappears and may have different values because of the boundary situation with the intersection of two MAs, although the distance between two MAs is set, it does not help. I thought I would take not the 0th value but the 1st one from the MA buffer, but it didn't work and I also thought I would skip this function before a new bar arrives and it didn't work either (I even tried to stop displaying anything). How to overcome this situation?

When flipping the chart right to left, also flickers indicator with constant recalculation

 
Sergey Dymov #:

Can you give me a hint?

In mql4 there was an indicator based on MA for opening price, it allowed to avoid re-rendering on the current bar. through int start() it worked fine. It showed everything clearly.

In mql5, the same indicator doesn't work through int start, it works through int OnCalculate. It keeps re-calculating and re-drawing, for a second the image disappears and may have different values because of the boundary situation with the intersection of two MAs, although the distance between two MAs is set, it does not help. I thought I would take not the 0th value but the 1st one from the MA buffer, but it didn't work and I also thought I would skip this function before a new bar arrives and it didn't work either (I even tried to stop displaying anything). How to overcome this situation?

When flipping the chart from right to left, also flickers indicator with constant recalculation

Ask the question here - they will definitely help.

 
Sergey Dymov #:

Can you give me a hint?

In mql4 there was an indicator based on MA on the opening price, it allowed to avoid re-rendering on the current bar. through int start() it worked fine. It showed everything clearly.

In mql5, the same indicator doesn't work through int start, it works through int OnCalculate. It keeps re-calculating and re-drawing, for a second the image disappears and may have different values because of the boundary situation with the intersection of two MAs, although the distance between two MAs is set, it does not help. I thought I would take not the 0th value but the 1st one from the MA buffer, but it didn't work and I also thought I would skip this function before a new bar arrives and it didn't work either (I even tried to stop displaying anything). How to overcome this situation?

When flipping the chart right to left, also flickers indicator with constant recalculation

Post the code
 

There is such a thing on the graphic

I've seen it done in any colour, if I'm not mistaken.

How?

Reason: