Comission on EA

 
How can I implement the broker commission in EA?

Tks a lot

Attached example

 
Alexandre Amaral:
Olá, como posso implementar a Comissão das broker no EA?

Tks a lot

Attached example

Explain better what you are asking, in english please.

 
Eleni Anna Branou:

Explain better what you are asking, in english please.

thanks for your message. I’d like to calculate the commission amount in my ea. I marked the column I want
 
Alexandre Amaral:
thanks for your message. I’d like to calculate the commission amount in my ea. I marked the column I want

With some code you mean? 

A coder could help you, because I can't.

 
Alexandre Amaral:
thanks for your message. I’d like to calculate the commission amount in my ea. I marked the column I want

Who is this broker that gives 3.8$ commission per LOT?

 
HousseXZ:

Who is this broker that gives 3.8$ commission per LOT?

I don’t know it’s a exemple, not my signal


 
Alexandre Amaral:
I don’t know it’s a exemple, not my signal


Please do not post links to signal services. That could be considered promotion and you could be banned as it is against forum rules.

I have removed the links.

 
Alexandre Amaral:
How can I implement the broker commission in EA?

Tks a lot

Attached example

For MetaTrader4 you can use OrderCommission()

For MetaTrader5 you should use a bit more complex approach with the loop through all history deals and HistoryDealGetDouble(ticket,DEAL_COMMISSION)

 
 Also check for MarketInfo MODE SPREAD, SPREAD IS ALSO COMMISSION
 
Alexandre Amaral:
How can I implement the broker commission in EA?

Tks a lot

Attached example


Tow-way:

  • You know the commission, asked by your broker, then you can use it in any order.
  • You don't know it. Then finde it with OrderCommission(); from an existing order and apply it for other case.
    Tick_Value=MarketInfo(Symbol(), MODE_TICKVALUE);
    int risk_percent = 10;
    double commision = 5; //last order commision or manualy inserted.
    
    lots = NormalizeDouble( (AccountBalance()*risk_percent/100 - 2*commision) / (Tick_Value* your_Order_sl_size), 2 );

 
Andrey Barinov:

For MetaTrader4 you can use OrderCommission()

For MetaTrader5 you should use a bit more complex approach with the loop through all history deals and HistoryDealGetDouble(ticket,DEAL_COMMISSION)

Thank you for your return Andrei. I forgot to mention, I use MT5 for the Brazilian market.


I understand that using the code below I can recover the commission amount.

   int deals,i,deal_ticket;
   deals = HistoryDealsTotal(); 

   for(i=0;i<deals;i++){ 
      deal_ticket = HistoryDealGetTicket(i); 
      
      Print( HistoryDealGetDouble(deal_ticket,DEAL_COMMISSION) );
   
   }
   

But can I define it? This is my problem. In the code, or in the terminal, I don't think where to do this. Exist a setComission function?


Tks all