Commission of a running position
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; }
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?