Before calling HistoryDealGetDouble you need to have invoked some kind of HistorySelect. PositionGetTicket will select the open position and not the deals. Search CodeBase for samples.
double GridManager::DealComission(ulong ticket) { if(HistorySelectByPosition(ticket)==true) { for(int i=HistoryDealsTotal()-1;i>=0;i--) { ulong deal_ticket=HistoryDealGetTicket(i); if(HistoryDealGetInteger(deal_ticket, DEAL_ENTRY) == DEAL_ENTRY_IN) return HistoryDealGetDouble(deal_ticket, DEAL_COMMISSION); } } return 0; }


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
Hello guys,
I made this script but it only shows 0.0 as a result when I drag the script into a chart with a running position. Can somebody tell me what's wrong with the code?