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

 

Good afternoon, everyone.

I'm learning about arrays.

Can you please tell me how to remove the value I need from an array?

As I understand it, after deleting a value, the size of the array will be reduced and probably

the new array size value will also need to be specified.

I haven't found the function that would delete an array value in the Reference Manual. Can you please show me what the whole procedure looks like?

so that after deleting, the array will continue to function.

Thank you.

Here is a concrete example of what I need.

int start()                                             
{

double mass[3]=
{
1.2414,
1.2438,
1.2874
};

double value =  Bid ;
int S = ArrayBsearch(mass,  value,  WHOLE_ARRAY,  0, MODE_ASCEND);

if ( Bid == mass[S]) //Bid = 1.2874
OrderSend(Symbol(),OP_SELL,0.1,Bid ,3,Ask+400*Point,Ask-200*Point,"jfh",123 );
}
// после того как открылся ордер по цене элемента массива с индексом 2 (1.2874)
// КАК УДАЛИТЬ ИЗ МАССИВА ЗНАЧЕНИЕ 1.2874 так что бы массив продолжил функционировать дальше.
 
ANDREY:

Good afternoon, everyone.

I'm learning about arrays.

Can you please tell me how to remove the value I need from an array?

As I understand it, after deleting a value, the size of the array will be reduced and probably

The new array size will also need to be specified.

I haven't found the function that would delete an array value in the Reference Manual. Please show me how the whole procedure looks like. to delete an array value,

So that after deleting, the array will continue to function.

Thank you.

Here's a concrete example of what I need.

You can copy an array "into itself" and then resize the array by decreasing it by 1. An example with deleting the zero index of the array and filling in the last one, but you can copy from any index any number of elements.

The second option is to overwrite the last value in the "freed" space and also reduce the size of the array.

Подскажите про массивы
Подскажите про массивы
  • 2017.12.03
  • www.mql5.com
Я только учусь и на массивах попал в засаду: пытаюсь написать скрипт в котором массив данных будет перезаписываться...
 
Alexey Viktorov:

You can copy an array "to itself" and then resize the array by decreasing it by 1. An example is deleting the zero index of the array and filling the last one, but copying can be done from any index with any number of elements.

The second option is to overwrite the last value in the "freed" space and also reduce the array size.

Thanks a lot for the tip.
 

Hello!!! Explain to me, even though I'm not a beginner, but I'm terribly sick of one single problem. I am calling the indicator from the indicator. When I receive a new bar with one value, I get completely different values when I recompile it right away. The delay in the calculation of the indicator by time leads to nothing. As a result, there is no automatic function at all. The question. WHY???? I'm so fed up I'm exhausted. What is this incredible glitch... I'm sick of it...

 

Hello! I can't solve the problem of moving the signal levels when the price goes beyond them. At the moment of compilation everything is OK, but in the tester, when the "suitable" condition comes, nothing changes. Please advise what is wrong with the condition of price moving beyond the signal levels?

//-------------------------выход цены за пределы сигнальных уровней-----------------------------------------------------------------------------------------------
 price=iHigh(Symbol(),PERIOD_M15,0);                                                               //Сигнальный уровень О(Сердцевина)
 ObjectCreate("UrO",OBJ_HLINE,0,0,price);
 ObjectSet("UrO",OBJPROP_COLOR,clrYellowGreen);                               
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
 priceA=price+30*Point;                                                                            //Сигнальный уровень А(Максимум)
 ObjectCreate("UrA",OBJ_HLINE,0,0,priceA);
 ObjectSet("UrA",OBJPROP_COLOR,clrDarkSlateBlue); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 priceB=price-30*Point;                                                                            //Сигнальный уровень B(Минимум)
 ObjectCreate("UrB",OBJ_HLINE,0,0,priceB); 
 ObjectSet("UrB",OBJPROP_COLOR,clrOrangeRed); 
//--------------------------------------------------------------------------
if((Bid>=priceA) ||(Bid<=priceB)){                                                                 //если цена вышла за одну из ГРАНИЦ, сдвинуть уровни
  ObjectSet("UrO",OBJPROP_PRICE1,iHigh(Symbol(),PERIOD_M15,0));  
                                                                                             

The"UrA" or"UrB" level should be moved to the last candle's maximum on m15, but it doesn't happen. Does anyone know why?

 
vikzip:

Hello! I can't solve the problem of moving the signal levels when the price goes beyond them. At the moment of compilation everything is OK, but in the tester, when the "suitable" condition comes, nothing changes. Please advise what is wrong with the condition of price moving beyond the signal levels?

The"UrA" or"UrB" level should be moved to the last candle's maximum on m15, but it doesn't happen. Does anyone know why?


What's wrong with ObjectMove()?

 
Vitalie Postolache:

What's wrong with ObjectMove()?


Thank you!!!)

 
Vitalie Postolache:

What's wrong with ObjectMove()?


The function is great! But the condition is not fulfilled for some reason! Does anyone know the reason?

  double price;                                                                                    //цена сердцевины
  double priceA;                                                                                   //цена верхнего сигнального уровня
  double priceB;                                                                                   //цена нижнего сигнального уровня
//+------------------------------------------------------------------------------------------------------------------------------------------------------------
int start(){
//-------------------------выход цены за пределы сигнальных уровней-----------------------------------------------------------------------------------------------

price=iHigh(Symbol(),PERIOD_M15,0);                                                               //Сигнальный уровень О(Сердцевина)
ObjectCreate("UrO",OBJ_HLINE,0,0,price);
ObjectSet("UrO",OBJPROP_COLOR,clrYellowGreen);                                                                                                                               
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
 priceA=price+30*Point;                                                                            //Сигнальный уровень А(Максимум)
ObjectCreate("UrA",OBJ_HLINE,0,0,priceA);
ObjectSet("UrA",OBJPROP_COLOR,clrDarkSlateBlue); 
//---------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 priceB=price-30*Point;                                                                            //Сигнальный уровень B(Минимум)
ObjectCreate("UrB",OBJ_HLINE,0,0,priceB); 
ObjectSet("UrB",OBJPROP_COLOR,clrOrangeRed); 
 //---------------------------------------------------------------------------------------------------------------------------------------------------------------
if((Bid<=priceB)||(Bid>=priceA)){                                                                 //если цена вышла за одну из ГРАНИЦ
  ObjectsDeleteAll();                                                                             //для примера удаляю все объекты, но этого не происходит!
  }                                                                                               //Почему ведь очевидно на тестере цена выходит за пределы, но ни чего не происходит???
return(0);
}
Can someone explain what is the error, please?
 

Hello!

I am just starting to learn MQL4. I cannot figure out why the script ignores the"Allow automatic trading" button in MT4 (ver. 4.0 build 1090)

I can't get a handle on this kind of construction:

int start()
{

     Alert("Привет!");

return;
}

I don't push the button, but it still shows a window with alert. When I set an order in a script, it fires it on every tick without stopping, whether the Autotrade button is pressed or not.


I have tried such a construction:


int start()
{

 while(!IsStopped())
    {
    
      Alert("Привет!");

     if(!IsExpertEnabled()) break;
    }


return;
}

At first it seemed to work, but in the process of complicating the script it also stopped working...

I don't know if it is supposed to be like this, but I don't feel the fluency of EA's work: when I change EA, the old one keeps working as if in the background, but maybe I haven't figured it out yet.

 
Dimitry-1983:

Hello!

I am just starting to learn MQL4. I cannot figure out why the script ignores the"Allow automatic trading" button in MT4 (ver. 4.0 build 1090)

I can't get a handle on this kind of construction:

I don't push the button, but it still shows a window with alert. When I set an order in a script, it fires it on every tick without stopping, whether the Autotrade button is pressed or not.


I have tried such a construction:


At first it seemed to work, but in the process of complicating the script it also stopped working...

I don't know if it is supposed to be like this, but I don't feel the fluency of EA's work: when I change EA, the old one keeps working as if in the background, but maybe I haven't figured it out yet.

This button only affects trading functions. Everything else remains working as it should.