Nobody knows
Use the code: HistoryPositionInfo version 2. (Sorry, at the moment the description is only in Russian and German)
Vladimir Karputov:
Use the code: HistoryPositionInfo version 2. (Sorry, at the moment the description is only in Russian and German)
Hello,
i never used it for the hole System. I use it only for the last trade
double last_deal_volume(const string symbol,const int magicnumber,const int deal_index) { // --- determine the time intervals of the required trading history datetime end=TimeCurrent(); // current server time datetime start=end-PeriodSeconds(PERIOD_H1)* Hours_Order_loockback;// set the beginning time to 24 hours ago //--- request in the cache of the program the needed interval of the trading history HistorySelect(start,end); //--- obtain the number of deals in the history int deals=HistoryDealsTotal(); int returns=0; double profit=0; double loss=0; double deal_volume =0; //--- scan through all of the deals in the history for(int i=0 ;i<deals-deal_index;i++) { //--- obtain the ticket of the deals by its index in the list ulong deal_ticket=HistoryDealGetTicket(i); if(deal_ticket>0) // obtain into the cache the deal, and work with it { string deal_symbol =HistoryDealGetString(deal_ticket,DEAL_SYMBOL); datetime time =HistoryDealGetInteger(deal_ticket,DEAL_TIME); ulong order =HistoryDealGetInteger(deal_ticket,DEAL_ORDER); long order_magic =HistoryDealGetInteger(deal_ticket,DEAL_MAGIC); long pos_ID =HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID); //--- process the deals with the indicated DEAL_MAGIC if(order_magic==magicnumber && deal_symbol == symbol) { deal_volume = HistoryDealGetDouble(deal_ticket,DEAL_VOLUME); } //--- calculate the losses and profits with a fixed results } else // unsuccessful attempt to obtain a deal { PrintFormat("We couldn't select a deal, with the index %d. Error %d", i,GetLastError()); } } //--- output the results of the calculations return(deal_volume); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double last_deal_profit(const string symbol,const int magicnumber, const int deal_index) { // --- determine the time intervals of the required trading history datetime end=TimeCurrent(); // current server time datetime start=end-PeriodSeconds(PERIOD_H1)*Hours_Order_loockback;// set the beginning time to 24 hours ago //--- request in the cache of the program the needed interval of the trading history HistorySelect(start,end); //--- obtain the number of deals in the history int deals=HistoryDealsTotal(); int returns=0; double profit=0; double loss=0; double deal_profit =0; //--- scan through all of the deals in the history for(int i=0 ;i<deals-deal_index;i++) { //--- obtain the ticket of the deals by its index in the list ulong deal_ticket=HistoryDealGetTicket(i); if(deal_ticket>0) // obtain into the cache the deal, and work with it { string deal_symbol =HistoryDealGetString(deal_ticket,DEAL_SYMBOL); datetime time =HistoryDealGetInteger(deal_ticket,DEAL_TIME); ulong order =HistoryDealGetInteger(deal_ticket,DEAL_ORDER); long order_magic =HistoryDealGetInteger(deal_ticket,DEAL_MAGIC); long pos_ID =HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID); //--- process the deals with the indicated DEAL_MAGIC if(order_magic==magicnumber && deal_symbol == symbol) { deal_profit = HistoryDealGetDouble(deal_ticket,DEAL_PROFIT); } } else // unsuccessful attempt to obtain a deal { PrintFormat("We couldn't select a deal, with the index %d. Error %d", i,GetLastError()); } } //--- output the results of the calculations return(deal_profit); }
amando

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
hi
i m unable to calculate history orders profit and loss in total. but i m very confuse about deals and orders. i tried both but not success. even some success with getting tickets all history from
HistoryOrderSelect . but there is not option to get Profit Value like POSITION_PROFIT.
can any one answer this mystery .now my head is hot.