Questions from Beginners MQL5 MT5 MetaTrader 5 - page 382

 
Please tell me the formula to calculate the lot size of a new order so that with tp of 10p it could withdraw a losing order to 0 and earn the desired 10 pips.
 

Which operator should be used to designatethe order type?

Combine 2 algorithms into one. (Combine them so there would not be a conflict of "OrdersTotal", it turns out that it will open 1 order. and I need 1 in each direction)

Thanks in advance))

int start ()

{

if (OrdersTotal() == 0 )

OrderSend("EURUSD",OP_BUY,Lots,Ask,0,0, "11",MagicNumb,0,Red);

}

int start ()

{

if (OrdersTotal() == 0 )

OrderSend("EURUSD",OP_SELL,Lots,Bid,0,0, "11",MagicNumb,0,Red);

}

 
le0nid2014:

Which operator should be used to designatethe order type?

Combine 2 algorithms into one. (Combine them so there would not be a conflict of "OrdersTotal", it turns out that it will open 1 order. and I need 1 in each direction)

Thanks in advance))

int start ()

{

if (OrdersTotal() == 0 )

OrderSend("EURUSD",OP_BUY,Lots,Ask,0,0, "11",MagicNumb,0,Red);

}

int start ()

{

if (OrdersTotal() == 0 )

OrderSend("EURUSD",OP_SELL,Lots,Bid,0,0, "11",MagicNumb,0,Red);

}

Open one by one.
 
Artyom Trishkin:
To open one by one.

If I have 0 orders it will open what I need.

I want it to open buy if there is no order to buy and vice versa (in the time when there is no 1 direction, 2 will open and the buy order will not start).

 
le0nid2014:

It will not work that way - when there are 0 orders it will open what I need.

I need it to open buy if there is no order to buy, and vice versa (while there is no 1 direction, there will be 2 and the start command will not be issued).

I have to count how many and open them if I do not have one.

 
new-rena:

count how many there are and, if the right one is missing, open

i do not know how to explain to the Expert Advisor which orders to buy and which to sell
 
//+------------------------------------------------------------------+
//| --- ФУНКЦИЯ РАСЧЕТА КОЛИЧЕСТВА ОРДЕРОВ
//+------------------------------------------------------------------+
   int Calc_Orders(string Symbols,string TYPE)
      {
         int Res=0; int calc;       
         for (calc=OrdersTotal()-1; calc>=0; calc--)
            {
               if (OrderSelect(calc,SELECT_BY_POS,MODE_TRADES))
                  {
                     if (TYPE=="BUY" && OrderType()==OP_BUY && OrderSymbol()==Symbols)
                        {
                           Res=Res+1;
                        }                        
                     if (TYPE=="SELL" && OrderType()==OP_SELL && OrderSymbol()==Symbols)
                        {
                           Res=Res+1;
                        }
                  }
            }
         return(Res);
      }
It won't fit in that post. tried editing it twice...
 
le0nid2014:

If I have 0 orders it will open what I need.

I want it to open buy if there is no order to buy and vice versa (in the time when there is no 1 direction, 2 will open and the buy order will not start).

I do not understand what you want. Is there any way to make it clearer?
 
Artyom Trishkin:
I do not understand what you want. Is there any way to explain it more clearly?

If there is no Sell or Buy order in the market, it opens such an order no matter how many Buy orders are there.

And vice versa.

 
le0nid2014:

If there is no Sell or Buy order in the market, it opens such an order no matter how many Buy orders are there.

And vice versa.

We set two local variables in the OnTick function of the bool type: buyExist = false and sellExist = false.

When a new tick comes, you check if there are any orders that belong to the given EA. If there is a sell order, sellExist = true and the same thing with the buy order. And then you check if buyExist = true - do not open a buy order. The same is true for sell. That is all.

Reason: