Develop and Implement a solution to handle groups of positions as a single entity and capture data for use by the main programme
I have developed a strategy concept that runs in MQL5 Hedging Mode, based on a concept of HOLDINGS (see below). I now require a programmer to change this concept into working code. The code needs to be easily read by me (I am not a programmer but have taught myself MQL5). I have some ideas on how this could be implemented via a new Class but am open to the Programmer determining the best method.
Main Functional Requirements
The main requirements are as follows:
1. Have multiple Holdings open at any one time.
2. Holdings can have from 1 to infinite positions
3. Each Holding must have a unique identifier (Holding.index). It is important to be able to identify Holdings in respect to Symbol, Timeframe, Group and Type.
4. Multiple Holdings will be active within any one main programme (i.e. same Magic Number).
5. Each Holding will be of a particular Group (eg. Scalping, Trend, Retracement, etc). In practice we want to use a Group number to identify this (Holding.group)
6. Each Holding will be of a Buy or Sell type (Holding.type)
7. Scaling is the process of adding a new position to an existing Holding. Thus this changes a number of parameters
8. Closing a Holding requires all positions within the Holding to beclosed.
9. DrawTradeActivity is a functionality that needs to draw information on screen to allow for simple visualisation and status of Holdings that have been opened/closed.
Holdings are always opened with a Market Order (ECN Broker) for the first position
Data is captured and written to files and/or added to a string DataArray for use by the main programme for plotting on-screen to a data panel. The Data Panel is not part of this scope.
The Customer is a not a programmer, although he has learnt rudimentary coding. Significantly, the customer has very little understanding of OOP and has found the implementation of the Array of Objects concept difficult to understand.
One of the requirements is that the code be written such that it is understandable and editable by the Customer. Therefore, it is important that:
- The code include commentary for clarification
- The code be structured logically as per the Specification unless it is otherwise agreed
- Coding shortcuts are avoided (eg: use if(x==false) rather than if(x!)
Given the customer is not a programmer, he does not know what he doen’t know. It is therefore important that the Programmer consider the objectives of the Specification and discuss/clarify with the Customer as requried.
We define a Holding as being a collection of linked positions that are treated as one single asset.
All positions within the Holding have the same direction (Buy/Sell), are of the same symbol and are placed by the same Trading Algorithm in the same Time Frame. However, the volume of positions within a Holding may differ.
Positions within a Holding are linked via a Holding Number. In practice, this is a counter that counts each Holding that has been opened by a particular Trading Algorithm. Each position is also provided with a Comment that uniquely identifies the Holding Number and the Position Number within the Holding. Thus, a position where the comment includes the number 14.003 means that this is the 3 rdposition of Holding #14.
In treating the Holding as a single asset, we aggregate:
- The Gross Profit
- The commissions of all positions
- The swap of all positions
- The Net Profit of all positions
- The volume of all positions
The Age of the Holding is calculated as the time elapsed from opening of the first position and once closed, the total age of the Holding is recorded as the time elapsed from the opening of the first position to the closing of the last position.
CTrade Class and Trade History Data
Obviously there is data available through existing classes and trade history.
These are available to be used. However, I require ALL data related to a Holding to be available in a single “container”. We do not want the main programme to pull data from different areas of MQL5/Terminal/Account etc.
Please see the link below: