Is this how you close order?

 

I was looking at this order type page https://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordercalcmargin_py#order_type

and i'm wondering, if there's no close order constant, instead if its just the  ORDER_TYPE_SELL constant that closes the underlying positions in the pair.

so i'm assuming, if i have 10 lots, buy position(s) open in GBPUSD, and i send in a sell order for 10 lots in GBPUSD, it is not going to place a new sell order for 10 lots, its just going to close previous buy position(s).

hence leaving me with net 0 lots open position in GBPUSD.

so if i send in a 15 lot sell order instead of 10 lots, it is going to close previous 10 lot buy positions(s) and will place 5 lot sell order in GBPUSD, (10 - 15 = -5)


I'm assuming this is correct, since i've built an algorithm around the stock market, they had the similar convention of things.

I just don't want to build an algorithm, around assuming things only to find out i missed or incorrectly assumed something critical, 3-4 months down the line 

Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
  • www.mql5.com
order_calc_margin - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

What about using a demo account to execute what you describe in the Strategy tester with hist. dates and in visual mode?

It is made exactly for this and your questions.

 
vinay88 :

I was looking at this order type page https://www.mql5.com/en/docs/integration/python_metatrader5/mt5ordercalcmargin_py#order_type

and i'm wondering, if there's no close order constant, instead if its just the  ORDER_TYPE_SELL constant that closes the underlying positions in the pair.

so i'm assuming, if i have 10 lots, buy position(s) open in GBPUSD, and i send in a sell order for 10 lots in GBPUSD, it is not going to place a new sell order for 10 lots, its just going to close previous buy position(s).

hence leaving me with net 0 lots open position in GBPUSD.

so if i send in a 15 lot sell order instead of 10 lots, it is going to close previous 10 lot buy positions(s) and will place 5 lot sell order in GBPUSD, (10 - 15 = -5)


I'm assuming this is correct, since i've built an algorithm around the stock market, they had the similar convention of things.

I just don't want to build an algorithm, around assuming things only to find out i missed or incorrectly assumed something critical, 3-4 months down the line 

You need to handle two cases yourself, depending on the type of your account:

Netting System or Hedging System .

 

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
Before you proceed to study the trade functions of the platform, you must have a clear understanding of the basic terms: order, deal and position...