fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. aminabazari
    3. Posts
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by aminabazari

    • bug in commission read

      There is a block named "Check profit (unrealized)"
      inside this block there is a function call named "OrderCommission()"
      this function returns 0. so the commission is not read correctly.
      instead of this function it's better to use following code which check commissions of all deals of current open position:

      double total_commission = 0.0;
      ulong ticket = PositionGetTicket(index);
      if(PositionSelectByTicket(ticket))
      {
      	// Select deals for this position
      	HistorySelect(0, TimeCurrent()); // select all history deals up to now
      	
      	int deals_total = HistoryDealsTotal();
      	for(int i = 0; i < deals_total; i++)
      	{
      	   ulong deal_ticket = HistoryDealGetTicket(i);
      	   ulong deal_position_id = HistoryDealGetInteger(deal_ticket, DEAL_POSITION_ID);
      	   
      	   if(deal_position_id == ticket)
      	   {
      		  double commission = HistoryDealGetDouble(deal_ticket, DEAL_COMMISSION);
      		  total_commission += commission;
      	   }
      	}
      }
      
      posted in Bug Reports
      A
      aminabazari
    • 1 / 1