Questions from Beginners MQL5 MT5 MetaTrader 5 - page 862

 
Konstantin Erin:
if(OrdersTotal() < OrdersMax) OrderSend(...); else Alert("The required number of orders opened");

Thank you !

 
can you tell me please where is the valume indicator and where can i find valume volumes ? !
 
int TotalGridBuyOrders=0;
   Print(__FUNCTION__);
   for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
   if(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its properties
         if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic && m_order.OrderType()== ORDER_TYPE_BUY_STOP)
           TotalGridBuyOrders++;
    Print("Количество buy ордеров grid ", TotalGridBuyOrders);
           if (TotalGridBuyOrders>=1)
           {
           grid_buy_price_memory=m_order.PriceOpen();        
           Print("Цена ближайшего buy grid ордера: ", grid_buy_price_memory);
           
          
int TotalGridSellOrders=0;
   Print(__FUNCTION__);
   for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
   if(m_order.SelectByIndex(i))     // selects the pending order by index for further access to its properties
         if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic && m_order.OrderType()== ORDER_TYPE_SELL_STOP)
           TotalGridSellOrders++;
    Print("Количество sell ордеров grid ", TotalGridSellOrders);
           if (TotalGridSellOrders>=1)   
            {
           grid_sell_price_memory=m_order.PriceOpen();    
           Print("Цена ближайшего sell grid ордера: ", grid_sell_price_memory);

Why does the last print display the price fromORDER_TYPE_BUY_STOP

and not fromORDER_TYPE_SELL_STOP

Where is the error ?

 
ilyav:

Why does the last print display the price fromORDER_TYPE_BUY_STOP

and not fromORDER_TYPE_SELL_STOP

Where is the mistake?

Use the styler (Ctrl + ,) and you will see your mistakes...

 
Vladimir Karputov:

Use the styler (Ctrl + ,) and you will see your mistakes...

I don't have a compilation error.

This code should output in Print the price of buy and sell orders.

The buy order price is output correctly but the sell order outputs the buy order price!

 
ilyav:

I don't have a compile-time error.

This code should output in Print the price of buy and sell orders.

The buy order price is correct, but the sell order price is correct!

At this point the advice is the same: use the styler - you will visually see the errors.

... and only then will I show you where your error is.
Стилизатор - Работа с исходным кодом - MetaTrader 5
Стилизатор - Работа с исходным кодом - MetaTrader 5
  • www.metatrader5.com
Данная функция предназначена для оформления исходного кода в соответствии с рекомендуемым стандартом. Это позволяет сделать код более читаемым, выглядящем профессионально. Грамотно оформленный код гораздо проще анализировать в последующем как его автору, так и другим пользователям. Для того чтобы запустить стилизатор, необходимо выполнить...
 
Vladimir Karputov:

For the moment, the advice remains the same: use a styliser - you will see the errors visually.

... And only after that I will show you where your error is.
int TotalGridBuyOrders=0;
         Print(__FUNCTION__);
         for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
            if(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its properties
               if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic && m_order.OrderType()==ORDER_TYPE_BUY_STOP)
                  TotalGridBuyOrders++;
         Print("Количество buy ордеров grid ",TotalGridBuyOrders);
         if(TotalGridBuyOrders>=1)
           {
            grid_buy_price_memory=m_order.PriceOpen();
            Print("Цена ближайшего buy grid ордера: ",grid_buy_price_memory);

            int TotalGridSellOrders=0;
            Print(__FUNCTION__);
            for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
               if(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its properties
                  if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic && m_order.OrderType()==ORDER_TYPE_SELL_STOP)
                     TotalGridSellOrders++;
            Print("Количество sell ордеров grid ",TotalGridSellOrders);
            if(TotalGridSellOrders>=1)
              {
               grid_sell_price_memory=m_order.PriceOpen();
               Print("Цена ближайшего sell grid ордера: ",grid_sell_price_memory);

Here it is with the styler. But I can't see the error. That's why I ask in the subject

Questions from Beginners in MQL5

 
ilyav:

Here's the one with the stylizer. But I don't see the error. That's why I am asking in this thread

Questions from Beginners in MQL5

The styler has clearly shown that your code contains problems with closing parentheses. You need to fix it.

 

Shit, can anyone here help?

If the styler clearly showed you something - couldn't you tell me where the bracket should be?

Because it didn't clearly show me anything.

I need the price of the nearest buy stop and the nearest sell stop. How can I make the code differently?

 
ilyav:

Shit, can anyone here help?

If the styler clearly showed you something - couldn't you tell me where the bracket should be?

Because it didn't clearly show me anything.

I need the price of the nearest buy stop and the nearest sell stop. How can I make the code differently?

I have highlighted the brackets that are missing pairs:

int TotalGridBuyOrders=0;
         Print(__FUNCTION__);
         for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
            if(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its properties
               if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic && m_order.OrderType()==ORDER_TYPE_BUY_STOP)
                  TotalGridBuyOrders++;
         Print("Количество buy ордеров grid ",TotalGridBuyOrders);
         if(TotalGridBuyOrders>=1)
           {
            grid_buy_price_memory=m_order.PriceOpen();
            Print("Цена ближайшего buy grid ордера: ",grid_buy_price_memory);

            int TotalGridSellOrders=0;
            Print(__FUNCTION__);
            for(int i=OrdersTotal()-1;i>=0;i--) // returns the number of current orders
               if(m_order.SelectByIndex(i)) // selects the pending order by index for further access to its properties
                  if(m_order.Symbol()==m_symbol.Name() && m_order.Magic()==m_magic && m_order.OrderType()==ORDER_TYPE_SELL_STOP)
                     TotalGridSellOrders++;
            Print("Количество sell ордеров grid ",TotalGridSellOrders);
            if(TotalGridSellOrders>=1)
              {
               grid_sell_price_memory=m_order.PriceOpen();
               Print("Цена ближайшего sell grid ордера: ",grid_sell_price_memory);

Where exactly to put the pairs depends on the logic of your code.

Reason: