Questions from Beginners MQL5 MT5 MetaTrader 5 - page 612

 
Karputov Vladimir:

1. Yes, that's right. Execution of an order generates a transaction. A transaction can:

  • create a position
  • change the size of a position
  • close a position
2. What could be better than practice? :) Open a position (manually) on any chart. Run the script

- pay attention to the line (look at the "Experts" tab of the terminal):

Increase volume, run the script again - compare the line again

As you can see, the position property (POSITION_IDENTIFIER) does not change if the position is not reversed.

Thank you! for the answers to you and all those who replied.
 
Karputov Vladimir:

In MT5 there is the concept of a POSITION. You can close a position. If you want to close a position completely, use the standard library. For a netting account an example of how to close a position:

Thank you!
 
Help please!

There is a string txt (downloaded from a news site)

string txt = "ИÐдеÑк ожиÐа´Ð½Ð¸Ð¹ в ÑÑ "еер уÑÐ "уг (авг)</a>\n";
original encoding UTF-8. is displayed as: windows 1252

needs to be converted by mql4 means into the form - Service Expectation Index (Aug)</a>

Thanks in advance!
 

Hello!

There is a piece of code

After it is executedPositionsTotal()

it shows 22 by the number of open orders (market orders). Indeed, 22 orders are open, but they are all for the same instrument. I think there should be only one position. What is wrong? Please advise!

position_ID=0;
  for(int i=0;i<PositionsTotal();i++)  {
      string pos_symbol=PositionGetSymbol((uint)i);
      if(pos_symbol==Symbol())  {
      position_ID=PositionGetInteger(POSITION_IDENTIFIER);  
      break;    
      }
  }    
   double mProfit =PositionGetDouble(POSITION_PROFIT);
PrintFormat("вход в 0018 PositionsTotal()=%d  mProfit=%d  ticket=%d",PositionsTotal(),mProfit,ticket); 
 
Alexander Kharlamov:

Hello!

There is a piece of code

After it is executedPositionsTotal()

it shows 22 by the number of open orders (market orders). Indeed, 22 orders are open, but they are all for the same instrument. I think there should be only one position. What is wrong? Please advise!

A position and an order are completely different things! A position is:"The result of thetrades is the opening of a position".

So if you have Buy or Sell orders, they are not orders, they were orders before the position was opened.

Also, the concept of "market order" does not exist, the order can be pending - Limit and Stop, as well as Stop Loss and Take Profit are also orders (order of the DC to close). Buy and Sell are positions, not orders, they are your positions in the market!

 
Vitaly Muzichenko:

A position and an order are completely different things! A position is:"The result of atrade is the opening of a position".

So if you have Buy or Sell orders, they are not orders, they were orders before the position was opened.

Also, the concept of "market order" does not exist, the order can be pending - Limit and Stop, as well as Stop Loss and Take Profit are also orders (order of the DC to close). Buy and Sell are positions, not orders, they are your positions in the market!

Thanks for the response, but your comment is clear to me. I meant market orders in the sense that they are already in the market, not pending orders. The question was why there are 22 positions, not just one. I think you didn't look at the code and immediately responded. Sorry...
 
Alexander Kharlamov:
Thank you for responding, but what you have written is clear to me as it is. I wrote market orders in the sense that they are already in the market, not pending. The question was why there are 22 positions, not just one. I think you didn't look at the code and immediately responded. Sorry...
Apparently you have a hedge account. There may be many positions in one instrument.
 
mila.com:

Hello.

Please tell me how to get the text located on the first bar into a variable.

I want to get int TXT = 191;


ObjectGetString()

OBJPROP_TEXT

Description of the object (text contained in the object)

string

 
Artyom Trishkin:

ObjectGetString()

OBJPROP_TEXT

Object description (text contained in object)

string

By means of
StringToInteger( 
   string  value      // строка 
   );
 
mila.com:

Thank you, it's not quite clear how to implement this in this case.

What's wrong with it?

Most likely there is no space between name and time "L_V "+Time[1]
Reason: