How do I close all orders at total profit in pips? - page 2

 
khasan kayumov:

How do you calculate the profit in points?

Before you delete

                    for(pos = 0; pos < 100500; pos++) 
                    {
                        if(OrderSelect(pos, SELECT_BY_POS))
                        if(OrderType() == OP_BUY)
                        {
                            buy_profit_USD = buy_profit_USD + OrderProfit() + OrderSwap() + OrderCommission();

                            buy_profit_Point = buy_profit_Point+ ((Bid - OrderOpenPrice()) / Point);

                                
                        }
                    }

 
Evgeny Belyaev:

Oh, yeah?

I place an order and it is rejected by the server, I get error 130.

What should I do and there is no position, there is nothing to close. I can only delete. What should I do or I am doing something wrong?

Do you really want me to answer you?
 
Dmitry Fedoseev:
Do you really want me to answer you?

No, I don't want the topic to turn into a flurry.

 
Evgeny Belyaev:

No, I don't want the topic to devolve into flubbing.


Then don't fluff it up.

 
Evgeny Belyaev:

I trade on the market, not on MT, MT is just an application which does not correctly define the name of the functions. Position - buy, set, defender, striker...

Order - order to place, buy, sell, defender, striker, midfielder...

Deal...


We are now on the forum of MT4. And the question is specifically about MQL4. So here it's quite appropriate to use the terminology introduced in MT4 and MQL4. After all, even functions of accounting that are called trades (constituent positions) begin with word "Order": OrderSend(), OrderClose(), OrderModify().

 
Ihor Herasko:

After all, even the functions accounting for what are called trades (constituent positions) on the exchange start with the word "Order": OrderSend(), OrderClose(), OrderModify().

The functions are undoubtedly called as such. In MT4, the name of the functions is not correct. The terminal is outdated, so the names are not correct.

Well, how can we understand each other?

We are talking about the same thing. If you call it a buy order, I will call it a position.

How do we understand each other?

 
Evgeny Belyaev:

The functions are undoubtedly called as such. In MT4 the names of the functions are not quite correct. The terminal is outdated, that's why the names are not correct.

Well, how do we understand each other?

We are talking about the same thing. If you call it a buy order, I will call it a position.

How do we understand each other?


I am used to using the terminology of the terminal. It may be wrong, but it helps me when reading the documentation. In MT4: market orders and pending orders. In MT5: trades, positions and orders. On other platforms: trades, positions, trades, orders.

 
Mikhail Sergeev:

                    for(pos = 0; pos < 100500; pos++) 
                    {
                        if(OrderSelect(pos, SELECT_BY_POS))
                        if(OrderType() == OP_BUY)
                        {
                            buy_profit_USD = buy_profit_USD + OrderProfit() + OrderSwap() + OrderCommission();

                            buy_profit_Point = buy_profit_Point+ ((Bid - OrderOpenPrice()) / Point);

                                
                        }
                    }

What is the number 100500? Why is that and not OrdersTotal()?

 
khasan kayumov:

How do you calculate the profit in pips?

Before you delete

//+------------------------------------------------------------------+
void OnStart()
  {
  double p;
   int i,pr=0;

   for(i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
        p=MarketInfo(OrderSymbol(), MODE_POINT);
         if(OrderType()==OP_BUY)
           {
            pr+=int((MarketInfo(OrderSymbol(), MODE_BID)-OrderOpenPrice())/p);
           }
         if(OrderType()==OP_SELL)
           {
            pr+=int((OrderOpenPrice()-MarketInfo(OrderSymbol(), MODE_ASK))/p);
           }
        }
     }   
   Alert( "суммарный профит открытых позиций в пунктах = ",pr); 
  }
//+------------------------------------------------------------------+

It goes like this.

 
Ihor Herasko:

I'm used to using terminology according to the terminal. It may be wrong, but it helps a lot when reading the documentation. In MT4: market orders and pending orders. In MT5: trades, positions, orders. On other platforms: trades, positions, trades, orders.


What if I didn't give a hint about the terminal? The terminology should be cross platform. There will be no problems in understanding the information.

I understand your point of view , I am tolerant of it , it is justified by the names of the functions.

If you have met 5 traders, one is using Quickquick, another one is using MT4, third one is using 5-Rouble, fourth one is trading via ninja, and the last one is using web terminal.

How do we reach a common denominator and how do we determine what is a position and what is an order?