당사 팬 페이지에 가입하십시오
CPairedDealInfo Class - MetaTrader 5용 라이브러리
- 조회수:
- 4595
- 평가:
- 게시됨:
- 2019.04.06 23:11
- 업데이트됨:
- 2021.10.24 23:14
- 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
CPairedDealInfo is a class to reconstruct closed trades (paired in/out deals) from history sorted by close time.
The class has a similar interface to CDealInfo class of the standard library.
class CPairedDealInfo : public CObject { public: CPairedDealInfo(void); ~CPairedDealInfo(void); //--- methods of access to protected data ulong TicketOpen(void) const { return(m_curr_ticket_in); } ulong TicketClose(void) const { return(m_curr_ticket_out); } //--- fast access methods to the integer deal properties datetime TimeOpen(void) const; ulong TimeOpenMsc(void) const; datetime TimeClose(void) const; ulong TimeCloseMsc(void) const; ENUM_DEAL_TYPE DealType(void) const; string TypeDescription(void) const; long Magic(void) const; long PositionId(void) const; long OrderOpen(void) const; long OrderClose(void) const; ENUM_DEAL_REASON OpenReason(void) const; ENUM_DEAL_REASON CloseReason(void) const; //--- fast access methods to the double deal properties double Volume(void) const; double PriceOpen(void) const; double StopLoss(void) const; double TakeProfit(void) const; double PriceClose(void) const; double Commission(void) const; double Swap(void) const; double Profit(void) const; //--- fast access methods to the string deal properties string Symbol(void) const; string OpenComment(void) const; string CloseComment(void) const; string OpenReasonDescription(void) const; string CloseReasonDescription(void) const; //--- info methods string FormatAction(string &str,const uint action) const; string FormatReason(string &str,const uint reason) const; //--- method for select deals bool HistorySelect(datetime from_date,datetime to_date); int Total(void) const; bool SelectByTicket(const ulong ticket); bool SelectByIndex(const int index); };
Here is a sample code showing how to use the class in your code
#include <CPairedDealInfo.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { //--- variable to hold the paired deals info CPairedDealInfo trade; //--- Reconstruct trades from the history of deals if(!trade.HistorySelect(0,TimeCurrent())) { Alert("CPairedDealInfo::HistorySelect() failed!"); return; } //--- now process the list of closed trades int total = trade.Total(); for(int i = 0; i < total; i++) { //--- Select a trade by its position in the list if(trade.SelectByIndex(i)) { ulong ticket_open = trade.TicketOpen(); ulong ticket_close = trade.TicketClose(); datetime time_open = trade.TimeOpen(); ulong time_open_msc = trade.TimeOpenMsc(); datetime time_close = trade.TimeClose(); ulong time_close_msc = trade.TimeCloseMsc(); long type = trade.DealType(); string type_desc = trade.TypeDescription(); long magic = trade.Magic(); long pos_id = trade.PositionId(); long order_open = trade.OrderOpen(); long order_close = trade.OrderClose(); double volume = trade.Volume(); double price_open = trade.PriceOpen(); double price_sl = trade.StopLoss(); double price_tp = trade.TakeProfit(); double price_close = trade.PriceClose(); double commission = trade.Commission(); double swap = trade.Swap(); double profit = trade.Profit(); string symbol = trade.Symbol(); string open_comment = trade.OpenComment(); string close_comment = trade.CloseComment(); string open_reason_desc = trade.OpenReasonDescription(); string close_reason_desc = trade.CloseReasonDescription(); } } //--- Print("Total closed trades = ",trade.Total()); } //+------------------------------------------------------------------+
Display interactive HTML graph of the account balance inside the web browser.
Pan PrizMA Sin leverage 72Builds a sliding line with a polynomial of 4 degrees. Extrapolates as a section of a given function with a sinusoid and its axial one. One value is taken from the constructed lines on each bar and a line of extrapolated values is plotted, which does not redraw.
The Expert Advisor uses four iMA (Moving Average, MA) indicators from two timeframes. Two indicators with averaging periods 1 and 8 are created on the H1 timeframe and two indicators with averaging periods 1 and 8 are also created on the H4 timeframe.
Hull moving averageHull moving average