22 April 2016
22 April 2016
Netting system
With this system, you can have only one common position for a symbol at the same time:
It does not matter, what has caused the opposite deal — an executed market order or a triggered pending order.
The below example shows execution of two EURUSD Buy deals 0.5 lots each:
Execution of both deals resulted in one common position of 1 lot.
Hedging system
With this system, you can have multiple open positions of one and the same symbol, including opposite position.
If you have an open position for a symbol, and execute a new deal
(or a pending order triggers), a new position is additionally opened.
Your current position does not change.
The below example shows execution of two EURUSD Buy deals 0.5 lots each:
Execution of these deals resulted in opening two separate positions.
New trade operation type - Close By
The new trade operation type has been added for hedging accounts —
closing a position by an opposite one. This operation allows closing
two oppositely directed positions at a single symbol. If the opposite
positions have different numbers of lots, only one order of the two
remains open. Its volume will be equal to the difference of lots of the
closed positions, while the position direction and open price will match
(by volume) the greater of the closed positions.
Compared with a single closure of the two positions, the closing
by an opposite position allows traders to save one spread:
In the latter case, a "close by" order is placed. Tickets of closed positions are specified in its comment. A pair of opposite positions is closed by two "out by" deals. Total profit/loss resulting from closing the both positions is specified only in one deal.
The tickets of orders and positions
(including history orders) are not preserved during import, because one
history record from MetaTrader 4 can be imported as up to 4 history
operations in MetaTrader 5. New tickets are assigned to all trading
records.
The account numbers can be preserved or replaced depending on how the broker imports them.
class CAnimal { public: CAnimal(); // Constructor virtual void Sound() = 0; // A pure virtual function private: double m_legs_count; // How many feet the animal has };Here Sound() is a pure virtual function, because it is declared with the specifier of the pure virtual function PURE (=0).
class CAnimal { public: virtual void Sound()=NULL; // PURE method, should be overridden in the derived class, CAnimal is now abstract and cannot be created }; //--- Derived from an abstract class class CCat : public CAnimal { public: virtual void Sound() { Print("Myau"); } // PURE is overridden, CCat is not abstract and can be created }; //--- examples of wrong use new CAnimal; // Error of 'CAnimal' - the compiler returns the "cannot instantiate abstract class" error CAnimal some_animal; // Error of 'CAnimal' - the compiler returns the "cannot instantiate abstract class" error //--- examples of correct use new CCat; // no error - the CCat class is not abstract CCat cat; // no error - the CCat class is not abstractRestrictions on abstract classes
//+------------------------------------------------------------------+ //| An abstract base class | //+------------------------------------------------------------------+ class CAnimal { public: //--- a pure virtual function virtual void Sound(void)=NULL; //--- function void CallSound(void) { Sound(); } //--- constructor CAnimal() { //--- an explicit call of the virtual method Sound(); //--- an implicit call (using a third function) CallSound(); //--- a constructor and/or destructor always calls its own functions, //--- even if they are virtual and overridden by a called function in a derived class //--- if the called function is purely virtual //--- the call causes the "pure virtual function call" critical execution error } };However, constructors and destructors for abstract classes can call other member functions.
typedef int (*TFunc)(int,int);Now, TFunc is a type, and it is possible to declare the variable pointer to the function:
TFunc func_ptr;The func_ptr variable may store the function address to declare it later:
int sub(int x,int y) { return(x-y); } int add(int x,int y) { return(x+y); } int neg(int x) { return(~x); } func_ptr=sub; Print(func_ptr(10,5)); func_ptr=add; Print(func_ptr(10,5)); func_ptr=neg; // error: neg is not of int (int,int) type Print(func_ptr(10)); // error: there should be two parametersPointers to functions can be stored and passed as parameters. You cannot get a pointer to a non-static class method.
ulong PositionGetTicket( int index // index in the list of positions );
bool PositionSelectByTicket(
ulong ticket // position ticket
);