Join our fan page
- Views:
- 3968
- Rating:
- Published:
- 2017.03.22 16:09
-
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
The CHistoryPositionInfo class is designed for getting the profit of a position in points based on the trading history.
Class Description
The CHistoryPositionInfo class allows getting the profit of a position in points based on the trading history.
Declaration
Title
Class Methods by Groups
Initialization | |
---|---|
Init | Initialization using a position ID |
Access to the calculation result | |
GetProfitInPoints | Getting the profit of a position in points |
Setting parameters | |
LogErrors | Enable/disable logging of errors |
PrintDeals(const bool value) | Enable/disable deal print mode |
Printing deals | |
PrintDeals(void) | Printing the deals that formed the position |
An example of using CHistoryPositionInfo:
//+------------------------------------------------------------------+ //| TestHistoryPositionInfo.mq5 | //| Copyright © 2017, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2017, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.003" #property script_show_inputs //--- input long position_id=0; // position identifier - POSITION_IDENTIFIER input bool log_errors=true; // logging errors input bool print_deals=true; // print deals #include <HistorySelect_\HistoryPositionInfo.mqh> //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- Print("\nSearch deals with POSITION_IDENTIFIER ",IntegerToString(position_id)); CHistoryPositionInfo HistoryPositionInfo; //--- init position identifier HistoryPositionInfo.Init(position_id); //--- los errors HistoryPositionInfo.LogErrors(log_errors); //--- print deals HistoryPositionInfo.PrintDeals(print_deals); //--- double profit_in_points=0.0; if(HistoryPositionInfo.GetProfitInPoints(profit_in_points)) Print("Profit in points ",DoubleToString(profit_in_points,1)); else Print("GetProfitInPoints=false"); } //+------------------------------------------------------------------+
Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/17622

An example of determining the moment when a pending order has triggered.

Keltner Channel built relative to the average value of the XCCX oscillator as a sequence of candlesticks

The CDir class allows getting information about files and folders outside the MQL5 sandbox similar to the MS-DOS Dir command. Call of system DLL is used, therefore you should allow their use.

The XRSXCandleKeltner indicator with the breakout indication option