fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    bug in commission read

    Bug Reports
    1
    1
    132
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aminabazari last edited by aminabazari

      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;
      	   }
      	}
      }
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post

      Online Users

      T
      B
      M
      C

      23
      Online

      146.9k
      Users

      22.4k
      Topics

      122.6k
      Posts

      Powered by NodeBB Forums | Contributors