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

 
Vitaly Muzichenko #:

Something about arrays

Looked at the profiling on the history of the speed

void Shift()
{
        for(int i=Bars(NULL, 0)-bars; i>0; i--)
        {
                ArrayInsert(arr, arr_sourse, 0);
        }
}

и

bool Shift()
{
        if(ArrayResize(arr, Bars(NULL, 0), Bars(NULL, 0)-bars+1000)<0) return false;
        for(int i=ArraySize(arr)-1; i>0; i--)
        {
                arr[i]=arr[i-1];
        }
        ArrayFill(arr, 0, Bars(NULL, 0)-bars, 0);
        return true;
}

Running costs are exactly the same.

As I understand it, under the bonnet of ArrayInsert is like that.

 
Afternoon
Can you advise me, are there any libraries for working with databases in mt4?
 

Greetings. Can you advise me please. mt5

I am trying to put indicator into EA, during testing/debugging it works on all ticks, data match. When testing on open prices data often diverge and when trying to find out the reason in the debugger a problem occurs - for the EA OnTick() is called once per candle and for the indicator OnCalculate() is called several times, once at the beginning and several times at the end of the candle, therefore data in variables change. In general, I need some help.


ozymandias_03 indicator

Files:
ozy_00.mq5  13 kb
 
Andrey Sokolov #:

Greetings. Can you advise me please. mt5

I am trying to put indicator into EA, during testing/debugging it works on all ticks, data match. When testing on open prices data often diverge and when trying to find out the reason in the debugger a problem occurs - for the EA OnTick() is called once per candle and for the indicator OnCalculate() is called several times, once at the beginning and several times at the end of the candle, therefore data in variables change. In general, I need some help.


ozymandias_03 indicator

Add data calculation to the indicator at the opening of the candle.
 

Good afternoon, all. I have an indicator that draws Fibonacci levels. I need the EA to place another EA with certain settings on this chart when the price reaches the 61.8 level on this Fibo grid and press the button to open an order.

Below is a screenshot of the indicator and the EA with its buttons.

Fibonacci drawn indicator

Fibonacci drawn by the indicator.


EA buttons

The Expert Advisor buttons should be clicked on the left Open


Is this thing really done? If so, how to implement it in words, and then in code? Please explain in as much detail and clearly as possible.

 
DanilaMactep #:

Good afternoon, all. I have an indicator that draws Fibonacci levels. I need the EA to place another EA with certain settings on this chart when the price reaches the 61.8 level on this Fibo grid and press the button to open an order.

Below is a screenshot of the indicator and the EA with its buttons.

Fibonacci drawn by the indicator.


The Expert Advisor buttons should be clicked on the left Open


Is this thing really done? If so, how to implement it in words, and then in code? Please explain in detail and understandably.

The "other" EA should be placed in the first one. In the first one, calculate the level and the code of the second EA starts working when it is reached. When the second starts, you have to prescribe the state of the button you want to press.

 
Andrey Sokolov #:

Insert the "other" EA into the first one. In the first one, calculate the level, when the second one reaches it, the code of the second one starts working. When the second one starts working, the state of the required button should be prescribed as pressed.

I forgot to specify that the source code of Expert Advisor with buttons is missing. Is there any way to do what I have in mind?

 
DanilaMactep #:

I forgot to mention that there is no source code for the EA with buttons. Is there any way to do what I have in mind?

If this is the case, then, as far as I know, it cannot be done with mql , without writing third-party software.

 
Tretyakov Rostyslav #:
Add data calculation to the indicator at the opening of the candle.

it was counting correctly there, I was watching incorrectly because the data here sometimes did not update with new candlesticks if the mouse was not moved


 
DanilaMactep #:

Good afternoon, all. I have an indicator that draws Fibonacci levels. I need the EA to place another EA with certain settings on this chart when the price reaches the 61.8 level on this Fibo grid and press the button to open an order.

Below is a screenshot of the indicator and the EA with its buttons.

Fibonacci drawn by the indicator.


The Expert Advisor buttons should be clicked on the left Open


Is this thing really done? If so, how to implement it in words, and then in code? Please explain in as much detail and clearly as possible.

The ChartApplyTemplate function loads the required template. If the template has the required Expert Advisor, then it will run.

If the buttons of the EA are made by standard objects, then it is possible (but not certain, this is done for work in the visual tester, and not all) that it will respond to ObjectSetInteger(chart,necessary_button,OBJPROP_STATE,1)

maybe you'll get lucky :-)