[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 519

 

Hello.

Smart people, advise a simple thing. I have three Expert Advisors working simultaneously on different currency pairs. If one of them wants to trade, how can I check, if there are already open trades on this currency pair? When only one Expert Advisor is working, everything is easy. OrderTotal(). When there are a lot of them, what to do?

 
Dozol:

Hello.

Smart people, advise a simple thing. I have three Expert Advisors working simultaneously on different currency pairs. If one of them wants to trade, how can I check, if there are already open trades on this currency pair? When only one Expert Advisor is working, everything is easy. OrderTotal(). When there are a lot of them, what to do?

An adult question! Have you heard anything about OrderMagicNumber()?
 
Pacman:

Good evening all.

I tried to write an indicator (it's my first indicator) which should display minimum and maximum price value among the last n bars.

I can't figure out where I'm going wrong.

Please help me to understand what i want to do!

The countdown starts from 1 bar.


Try it:

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 DeepSkyBlue

extern int Quant_Bars = 5; //количество баров

double Line_1[];     //объявление массивов под..
double Line_2[];     //..буферы индикаторов

int init()
  {//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);    //стиль линии
   SetIndexBuffer(0,Line_1);                    //назнач. массива буферу
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);    //стиль линии
   SetIndexBuffer(1,Line_2);                    //назнач. массива буферу
    return(0);}

int start()
  {double Minimum=1000005; //минимум за n баров
   double  Maximum;      //максимум за n баров
   int z,k; 
  for(z=1;z<Quant_Bars;z++)
   {if(Low[z]<Minimum)    //если меньше известного..
       Minimum=Low[z];    //..то оно и будет минимальным
    if(High[z]>Maximum)    //если большн известного..
       Maximum=High[z];    //..то оно и будет максимальным
    }
for(k=1;k<Quant_Bars;k++)     
  {Line_1[k]=Minimum;    //отобразить линию минимума
   Line_2[k]=Maximum;    //отобразить линию максимума
  }return(0);}
 

TarasBY:
Взрослый вопрос! Про OrderMagicNumber() что-нибудь слышали?

Heard it. I don't see how it will help me in solving my problem.

Let me rephrase the question: how do I determine whether there are open trades on a particular currency pair or not?

 
Dozol:
Before you search for "your" (opened by a specific advisor) order, you need to assign it a unique MAGIC when it is opened. And then use the MAGIC to decide your question.
 
TarasBY:
Before you look for "your" (open by a specific EA) order, you need to assign it a unique MAGIC when you open it. And then, using the MAGIC, your question will be solved.


You can also use the OrderSymbol() command

like this

int count_orders=0;

string Symbole=eurusd;

  for (int i = OrdersTotal() - 1; i >= 0; i--)

    {

        OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

        if ( OrderSymbol()==Symbole) count_orders=count_orders+1;

   } 
 
Hello Dear forum users, I'm a newbie, I'm writing my first Expert Advisor, can you help me fix an algorithmic bug, (closing orders by criterion does not work((?)), here is a file ...
 
Equilibrium:
Hello Dear forum users, I am a newbie, I am writing my first Expert Advisor, can you help me fix an algorithmic error, (closing orders by criterion does not work((?), here is the file...

would you add a message to log when order closes or does it not work at all to try to close?
 

Hello all.

Can you please tell me if there are ways to output elements of a one-dimensional array to comment () (or something else), and the size of the array can vary, but it's unlikely to be more than 20 elements there in my case.

 
Lians:

Hello all.

Can you please tell me if there are ways to output elements of a one-dimensional array to comment() (or something else), and the size of the array can vary, but it's unlikely to be more than 20 elements there in my case.

In the loop, consecutively read all the elements of the array and form one string variable (with separators) from them. And output this variable to Comment.
Reason: