Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 997

 

Hi all) decided to make a robot) - ) )

In short, the problem of not knowing how to check the number of orders on the current chart (Example algorithm - IF on the --(((( LIKE)))) -- open orders <=2 then buy, sell, etc.

- I have all orders and because of the large number of orders does not buy on the currency pair on which it is necessary

I am looking for an answer.)

I would be very thankful)

 
Tema97:

Hi all) decided to make a robot) - ) )

In short, the problem of not knowing how to check the number of orders on the current chart (Example algorithm - IF on the --(((( LIKE)))) -- open orders <=2 then buy, sell, etc.

- I have all orders and because of the large number of orders does not buy on the currency pair on which it is necessary

I am looking for an answer.)

I would be very grateful)

int count=0; // счетчик открытых ордеров

//--- алгоритм подсчета открытых ордеров

if(OrdersTotal()>0)
  {
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()!=Symbol()) continue; // Если не символ текущего графика
                                               // перейдём к проверке следующего ордера

         if(OrderType()==OP_BUY ||     // если это открытый ордер на покупку или
            OrderType()==OP_SELL)      // если это открытый ордер на продажу
            count++;                   // увеличение счетчика на 1
        }
     }
  }

//--- покупаем, продаем и т.д.
if(count<=2)
  {
   // ...
  }
 
if(OrdersTotal()>0)
А это зачем?????????

	          
 
eevviill:

it is like - if there are more than 0 orders, then continue the algorithm (as if there are bought or 0 - if there are zero, then why do the algorithm)

 
paladin80:

Thanks a lot ) I've been struggling since yesterday )
 
Tema97:

it is like - if there are more than 0 orders, then continue the algorithm (as if there are bought or 0 - if there are zero, then why do the algorithm)

for(int i=OrdersTotal()-1; i>=0; i--)
тут даже не будет 1 итерации если ордеров 0
это просто лишний код(if(OrdersTotal()>0))
 
Dudes who will help this time? - I wrote a code - I got a weird one - I need the price to go from the top to the bottom to themoving average and buy (like a bounce) - if you know the right code, please let me know)))
 
eevviill:

If you use this algorithm in your programs, remove it

if(OrdersTotal()>0)

and see what happens.

 
Tema97:
Dudes who can help this time? - I wrote a code - I got a weird one - I need the price to go from the top to the bottom to the moving average and buy (like a bounce) - if you know the right code, please let me know)))
The CodeBase has a ton of EAs and I think you will find some with your algorithm that you can recreate for yourself.
 
paladin80:
CodeBase has a bunch of Expert Advisors and I think there's one with your algorithm that you can remake for yourself.
ooh thanks for the info ) well i'm gonna sing wahahahahahaha))))
Reason: