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

 
Alexey Viktorov:

string AUDUSD = "AUDUSD";

At least like this.

That's it!!! That's how it was for me))), erased and forgotten))

Thank you so much!!! Peace in your home!

 
Valeriy Yastremskiy:

Expert Advisor, script, indicator are not accessed, but work in the current window. And global variables of different windows/charts do not overlap. Therefore, it should work)

string AUDUSD; // This is a text variable, besides being initially empty, i.e. equal to ""

(Symbol() == AUDUSD) // this string has nothing to do with variable AUDUSD.

But the order opening criteria should not be the same for different instruments/windows. If they are the same, it will indeed open in all windows.

Thank you!

I implemented the logic so that the Expert Advisor would not get the signal to open orders when they open in several windows and would understand that the buy signal was given for such a symbol so the EA would not interfere with others.

 
Denis Diakonov:

There it is!!! That's how it was for me))), erased and forgotten))

Thank you so much!!! Peace into your home!

Or like this on a global variable level

#define  AUDUSD "AUDUSD"
 
Alexey Viktorov:

Or like this on global variable level

Actually it is cool)) Now the robot gets a signal and opens orders on different pairs in several windows at once))

Thanks again!

 
Yerkin Sagandykov:

The problem is not in the values of the variable in my opinion. I just have in my code uulsovii recalculation at the occurrence of a new hour. and it turns out that the current symbol new bar appears and calculated the value of bar = 1, but the signal symbol is a new bar has not yet been formed or what is the value for a bar = 2

The problem is solved easily - I just tracked the start of a new bar by the signal symbol

 if  ( iTime(nameSym, LPeriod, 0 ) == counted_bar || iTime(nameSymSignal, LPeriod, 0 ) == counted_Signalbar) return; 
 
Please give me a hint.
Is it possible to pass several switch case parameters from the function body? I have types of orders to be opened in switch case and I managed to pass only 1 parameter to open an order from the function defining market entry point, as I already understood it is impossible, so I don't know how to implement it even sequentially
 
Denis Diakonov:
Please advise.
Is it possible to pass several switch case parameters from the function body? I have types of orders to be opened in switch case and I managed to pass only 1 parameter to open an order from the function defining market entry point, as I already understood it is impossible, so I don't know how to implement it even sequentially yet

Please show me in the code what exactly you are interested in

 
Denis Diakonov:
Please advise.
Is it possible to pass several switch case parameters from the function body? I have types of orders to be opened in switch case and I have managed to pass only 1 parameter to open an order from the function defining market entry point, as I already understood it is impossible, so I don't know how to implement it even sequentially

Are you referring to a range of values?

 
Vitaly Muzichenko:

Show the code exactly what you are interested in

int OpenOrder()                                             
{
   switch(AUDUSD_Analizing)
   {
      case 0 : Alert("Нет условий для открытия ордера. Выход"); break;    
      case 1 : // кейс для открытия Buy по AUD/USD
               if(TimeServer() == true)                                     
               {
                  if(Symbol() == AUDUSD)
                  {
                  RefreshRates();
                  Open_Order = OrderSend("AUDUSD",OP_BUY,lot,Ask,0,0,0); 
                  Alert("Тикет открытого ордера ", Open_Order, GetLastError());
      case 2 : // кейс для открытия Sell по AUD/USD
               if(TimeServer() == true)                                     
               {
                  if(Symbol() == AUDUSD)
                  {
                  RefreshRates();
                  Open_Order = OrderSend("AUDUSD",OP_SELL,lot,Bid,0,0,0); 
                  Alert("Тикет открытого ордера ", Open_Order, GetLastError());
//-------------------------------------------------------------------------------------------------------------
// другая функция
//-------------------------------------------------------------------------------------------------------------

int AUDUSD_Analizing()
{    
   if(AUDUSD_Prices_new > AUDUSD_Prices_old)
   {
      s1 = AUDUSD_Prices1;
      s2 = AUDUSD_Prices2;
      s3 = s1 - s2;    
      if(raznica > s5)
      {
         Alert("--- ВРЕМЯ ОТКРЫВАТЬ ОРДЕР НА ПОКУПКУ ---");

и вот тут я могу либо прописать конкретное открытие ордера или несколько их штук(чем и решил заняться так 
как не нашел решения), либо вернуть номер кейса в первую функцию(что сократило бы код). 
Но мне нужно по условиям открывать сразу несколько сделок. К примеру нужно 2 на бай разом открыть, 
а возвращается только одно значение и исполняется один кейс и дальше уже на новый круг все идет, 
а мне нужно сразу несколько кейсов, допустим 5 выполнить, поставить 5 отложек и вот как передать не пойму, 
или как вызвать срабатывание кейсов в последовательности. Если с кейсами можно как-то придумать, то по
факту код влезет в рамку 400-600 строк, а так полагаю все 1000+ выйдет в лучшем случае
(разбитые по 100-200 строк на .mqh, но и из файлов тоже помойка сложится)

 
Alexey Viktorov:

Do you mean a range of values?

No, for example pass case 1 first, then case 2, etc.

cases execute the opening of orders

Reason: