How to start with MQL5 - page 32

Vladimir Karputov
Moderator
286047
diamondiptv # :
Here is my screenshot example for GBPUSD every position charges 0.10 at opening 0.05 and after close another 0.05

Why are you showing MOBILE TERMINAL? You need to look in the terminal for the desktop version of Windows!

Forum on trading, automated trading systems and testing trading strategies

How to start with MQL5

Vladimir Karputov, 2021.10.16 13:03

Show the "trade" tab of your terminal - I'm interested in what you write in the "Commission" column.


diamondiptv
30
diamondiptv  
Vladimir Karputov #:

Why are you showing MOBILE TERMINAL? You need to look in the terminal for the desktop version of Windows!


my terminal at windows "trade" tab there's no commission column

commission column only appear at "history" tab with total of charges for the order

in this case should i use  trade history instead of open trades ?


Vladimir Karputov
Moderator
286047
diamondiptv # :

my terminal at windows "trade" tab there's no commission column

commission column only appear at "history" tab with total of charges for the order

in this case should i use  trade history instead of open trades ?


I do not have a symbol on which the commission is taken when opening - so I cannot check it. Please check it yourself.

Sergey Golubev
Moderator
124460
Sergey Golubev  
diamondiptv #:

my terminal at windows "trade" tab there's no commission column

commission column only appear at "history" tab with total of charges for the order

in this case should i use  trade history instead of open trades ?


read this small thread with the discussion: https://www.mql5.com/en/forum/342714 - for example:

Forum on trading, automated trading systems and testing trading strategies

desktop mt5 miss trading tab "commission"?!

Alain Verleyen, 2020.06.04 02:47

That's not a rule. On MT5, the commission can be charged in a lot of different ways.

Forum on trading, automated trading systems and testing trading strategies

New MetaTrader 5 platform build 2170: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates

MetaQuotes, 2019.10.03 15:18

The MetaTrader 5 platform update will be released on Friday, October 4, 2019 The new version features the following changes:

  1. Terminal: Completely redesigned built-in Virtual Hosting management options. All information about the rented terminal, as well as environment migration, stop and start functions, are now available in a separate tab of the Toolbox window.

    ...
  2. Terminal: Added ability to quickly switch to deposit/withdrawal operations on the broker website.

    ...
  3. Terminal: New fields in the trading symbol specification:

    ...

    Commissions
    Information on commissions charged by a broker for the symbol deals. Calculation details are displayed here:

    • Commission may be single-level and multilevel, i.e. be equal regardless of the deal volume/turnover or can depend on the size. Appropriate data is displayed in the terminal.
    • Commission can be charged immediately upon deal execution or at the end of a trading day/month.
    • Commission can be charged depending on deal direction: entry, exit or both operation types.
    • Commission can be charged per lot or deal.
    • Commission can be calculated in money, percentage or points.

    For example, the following entry means that a commission is charged immediately upon deal entry and exit. If the deal volume is between 0 to 10 lots, a commission of 1.2 USD is charged per operation. If the deal volume is between 11 to 20 lots, a commission of 1.1 USD is charged per each lot of the deal.
    Commission | Instant, volume, entry/exit deals
    0  - 10  | 1.2 USD per deal
    11 - 20  | 1.1 USD per lot





In all cases, it's not available in the Trade Tab.


desktop mt5 miss trading tab "commission"?!
desktop mt5 miss trading tab "commission"?!
  • 2020.06.03
  • www.mql5.com
i have commission shown in trading tab of toolbox but why not on mt5...
diamondiptv
30
diamondiptv  
Vladimir Karputov #:

I do not have a symbol on which the commission is taken when opening - so I cannot check it. Please check it yourself.

thank you for your help

if i want to count commission after trde closed how i do that

thanks in advance

diamondiptv
30
diamondiptv  
Sergey Golubev #:

read this small thread with the discussion: https://www.mql5.com/en/forum/342714 - for example:


thanks it helps
Vladimir Karputov
Moderator
286047

Last N DEAL_ENTRY_OUT

Code: 'Last N DEAL_ENTRY_OUT.mq5'

//+------------------------------------------------------------------+
//|                                        Last N DEAL_ENTRY_OUT.mq5 |
//|                              Copyright © 2021, Vladimir Karputov |
//|                      https://www.mql5.com/en/users/barabashkakvn |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2021, Vladimir Karputov"
#property link      "https://www.mql5.com/en/users/barabashkakvn"
#property version   "1.000"
//--- input parameters
input uchar    InpN        = 3;  // N
input datetime InpFromDate = 0;  // From Date (D'1970.01.01 00:00' -> OFF parameter)
input string   InpSymbol   = ""; // Symbol ("" -> all symbols)
input long     InpMagic    = -1; // Magic number (<0 -> all magics)
//---
datetime m_from_date       = 0;  // "0" -> D'1970.01.01 00:00';
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- request trade history
   HistorySelect(InpFromDate,TimeTradeServer()+60*60*24*3);
   uint total_deals=HistoryDealsTotal();
   ulong ticket_history_deal=0;
   int counter=0;
   string text="";
//--- for all deals
   for(uint i=total_deals-1; i>=0; i--)
     {
      //--- try to get deals ticket_history_deal
      if((ticket_history_deal=HistoryDealGetTicket(i))>0)
        {
         long     deal_ticket       =HistoryDealGetInteger(ticket_history_deal,DEAL_TICKET);
         long     deal_time         =HistoryDealGetInteger(ticket_history_deal,DEAL_TIME);
         long     deal_type         =HistoryDealGetInteger(ticket_history_deal,DEAL_TYPE);
         long     deal_entry        =HistoryDealGetInteger(ticket_history_deal,DEAL_ENTRY);
         long     deal_magic        =HistoryDealGetInteger(ticket_history_deal,DEAL_MAGIC);
         double   deal_commission   =HistoryDealGetDouble(ticket_history_deal,DEAL_COMMISSION);
         double   deal_swap         =HistoryDealGetDouble(ticket_history_deal,DEAL_SWAP);
         double   deal_profit       =HistoryDealGetDouble(ticket_history_deal,DEAL_PROFIT);
         string   deal_symbol       =HistoryDealGetString(ticket_history_deal,DEAL_SYMBOL);
         //---
         if((InpSymbol==deal_symbol || InpSymbol=="") && (InpMagic==deal_magic || InpMagic<0))
           {
            if(deal_entry==DEAL_ENTRY_OUT)
              {
               counter++;
               string time=TimeToString((datetime)deal_time,TIME_DATE|TIME_MINUTES|TIME_SECONDS);
               text=text+"\n"+time+" | "+DoubleToString(deal_commission+deal_swap+deal_profit,2);
               if(counter==InpN)
                 {
                  m_from_date=(datetime)deal_time;
                  break;
                 }
              }
           }
        }
     }
   Comment(text);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- request trade history
   HistorySelect(m_from_date,TimeTradeServer()+60*60*24*3);
   uint total_deals=HistoryDealsTotal();
   ulong ticket_history_deal=0;
   int counter=0;
   string text="";
//--- for all deals
   for(uint i=total_deals-1; i>=0; i--)
     {
      //--- try to get deals ticket_history_deal
      if((ticket_history_deal=HistoryDealGetTicket(i))>0)
        {
         long     deal_ticket       =HistoryDealGetInteger(ticket_history_deal,DEAL_TICKET);
         long     deal_time         =HistoryDealGetInteger(ticket_history_deal,DEAL_TIME);
         long     deal_type         =HistoryDealGetInteger(ticket_history_deal,DEAL_TYPE);
         long     deal_entry        =HistoryDealGetInteger(ticket_history_deal,DEAL_ENTRY);
         long     deal_magic        =HistoryDealGetInteger(ticket_history_deal,DEAL_MAGIC);
         double   deal_commission   =HistoryDealGetDouble(ticket_history_deal,DEAL_COMMISSION);
         double   deal_swap         =HistoryDealGetDouble(ticket_history_deal,DEAL_SWAP);
         double   deal_profit       =HistoryDealGetDouble(ticket_history_deal,DEAL_PROFIT);
         string   deal_symbol       =HistoryDealGetString(ticket_history_deal,DEAL_SYMBOL);
         //---
         if((InpSymbol==deal_symbol || InpSymbol=="") && (InpMagic==deal_magic || InpMagic<0))
           {
            if(deal_entry==DEAL_ENTRY_OUT)
              {
               counter++;
               string time=TimeToString((datetime)deal_time,TIME_DATE|TIME_MINUTES|TIME_SECONDS);
               text=text+"\n"+time+" | "+DoubleToString(deal_commission+deal_swap+deal_profit,2);
               if(counter==InpN)
                 {
                  m_from_date=(datetime)deal_time;
                  break;
                 }
              }
           }
        }
     }
   Comment(text);
  }
//+------------------------------------------------------------------+

Result:


Files:
chandan kumar
10
chandan kumar  
Sergey Golubev #:

read this small thread with the discussion: https://www.mql5.com/en/forum/342714 - for example:


i m using a third party EA. it has an option " back tester simulated commission"...set to 7.0 by default.

what is it and if i set it to zero then??

thanks in advance.

Sergey Golubev
Moderator
124460
Sergey Golubev  
chandan kumar #:

i m using a third party EA. it has an option " back tester simulated commission"...set to 7.0 by default.

what is it and if i set it to zero then??

thanks in advance.

I do not know ... I think - it depends on the broker.
read first post of this thread about commissions:
https://www.mql5.com/en/forum/323540
New MetaTrader 5 platform build 2170: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates
New MetaTrader 5 platform build 2170: MQL5 scope, global Strategy Tester and built-in Virtual Hosting updates
  • 2019.10.03
  • www.mql5.com
The MetaTrader 5 platform update will be released on Friday, October 4, 2019 The new version features the following changes: Terminal: Completely...
DroidM
83
DroidM  
Im confused as to how i can go about accessing a desired candle on a higher timeframe. For example, an array of candle closes for 1 min candles is close[]
My strategy picked out close[8] which was at 1.69230 how can i find out on which candle in the m5 chart was at 1.69230