MetaTrader 5 Python User Group - the summary - page 7

 

Hello All

I recently started using the MetaTrader5 python package. everything works fine, getting data, getting open positions. The problem I have is sending orders. I tried the example provided and got the following message: 


In [4]: import MetaTrader5 as mt5

In [5]: mt5.initialize()

Out[5]: True


In [6]: mt5.Sell("EURUSD", 0.001)

Out[6]: OrderSendResult(retcode=10030, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Unsupported filling mode', request_id=0, retcode_external=0)


it seems metatrader has a problem with the way the order is sent. Please help

 
pip install MetaTrader5

ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)

ERROR: No matching distribution found for MetaTrader5


I couldn't install MetaTrader5 using pip install. The error was as below.

Anyone can help me? Thanks a lot.

 
nvicki112:

ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)

ERROR: No matching distribution found for MetaTrader5


I couldn't install MetaTrader5 using pip install. The error was as below.

Anyone can help me? Thanks a lot.

I think - it is better to wait - because of the following:

Next Friday we will make the MT5 release, while updating the documentation.

We will describe later in the documentation.

So, it is etter to wait for Friday when everything (new functions etc) will be described in the documentation with the examples.

 
Please developer, make a distribution for Python 3.5.0. It is a humble request. My all codes are on Python 3.5.0 and I have to change the whole project if I upgrade to another Python version. Please consider my request.
 

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 Python User Group - how to use Python in Metatrader

Renat Fatkhullin , 2020/02/18 22:05

A beta version of terminal 2323 with new features is available in the test server (MetaQuotes-Beta server, address 78.140.180.203-00-0043). A public beta build will be available tomorrow.

We also released a new version of MetaTrader 5.0.20 for Python (pip install --upgrade metatrader5) with a new syntax for switching accounts:

import MetaTrader5 as mt5

mt5.initialize(timeout= 10000 )
mt5.initialize(login= 25035662 , password= "oxeb7lpb" , server= "MetaQuotes-Demo" )
mt5.login( 25035662 )
mt5.login( 25035662 , timeout= 10000 )
mt5.login( 25035662 , "oxeb7lpb" )
mt5.login( 25035662 , password= "oxeb7lpb" )
mt5.login( 25035662 , password= "oxeb7lpb" , server= "MetaQuotes-Demo" )

Now you can specify authorization directly in the initialization, both in full and in short.

The wait function has been canceled and now the full initialization cycle with the wait is done right in initialize, where you can also set the timeout in milliseconds.

The Python library is already guaranteed to find the latest active copy of the terminal, even if it was installed in the portable (key / portable) mode.


Python programs are already shown right in the navigator:


In the release this Friday, they can already be fully launched as normal MQL5 scripts and they will be attached to the charts.


In the future, we will add to the Python library access to all (including custom) indicators in read mode. This will make work in python more productive. But this is not a priority, we will do it much later.


 

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 Python User Group - how to use Python in Metatrader

Renat Fatkhullin , 2020/02/18 22:15

In parallel, we are expanding the capabilities of the editor and in the next release (not coming Friday) there will be a full opportunity to use Clang / LLVM and Microsoft Visual Studio to compile C ++ programs:


Perhaps C # will be included.


A lot of work was done to make full use of SQLite databases: SQLite: native work with SQL databases in MQL5

This allows you to conveniently operate and exchange large amounts of data between different systems and inside the terminal.


 

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 Python User Group - how to use Python in Metatrader

Renat Fatkhullin , 02/20/19 08:53

Within the framework of projects, you can specify many target options:



DLL / EXE files have custom define settings, libraries, and additional parameters for the compiler:

The linker is automatically used by Clang or Visual Studio. Explicitly do not specify it.


 

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 Python User Group - how to use Python in Metatrader

Renat Fatkhullin , 02/20/19 09:05

Build 2323 is already available on MetaQuotes-Demo and by update command on beta versions from the help menu.

Do not forget to upgrade to the MetaTrader 5.0.20 library for Python, please.


 
similodingile:

Hello All

I recently started using the MetaTrader5 python package. everything works fine, getting data, getting open positions. The problem I have is sending orders. I tried the example provided and got the following message: 


In [4]: import MetaTrader5 as mt5

In [5]: mt5.initialize()

Out[5]: True


In [6]: mt5.Sell("EURUSD", 0.001)

Out[6]: OrderSendResult(retcode=10030, deal=0, order=0, volume=0.0, price=0.0, bid=0.0, ask=0.0, comment='Unsupported filling mode', request_id=0, retcode_external=0)


it seems metatrader has a problem with the way the order is sent. Please help

FXPro related problem. changed the account to FXTIME and everything worked fine. 
 

Forum on trading, automated trading systems and testing trading strategies

New MetaTrader 5 Platform Build 2340: Managing account settings in the Tester and expanded integration with Python

MetaQuotes, 2020.02.20 14:59

The MetaTrader 5 platform update will be released on Friday, February the 21st, 2020. The new version features the following changes:

  1. MetaEditor: Added new functionality for working with SQLite databases.

    In the previous platform update, we introduced support for operations with SQLite databases directly from MQL5. The main functions have become available through the MetaEditor user interface:

    • Create and connect databases
    • View tables and perform quick data queries
    • Create and execute SQL queries, rollback changes

    How it works
    The quick database creation functionality is available from the MQL5 Wizard. You can easily create your first table and define its fields.




    Upon the database creation, you will be forwarded to a new Navigator section, which features commands for managing the data.

    Database tables are shown in the left-hand window. Double-click on the table name to quickly query the first 1,000 records. In this navigator section, you can also create and open other databases, as well as work with tables.

    The database can be managed in the main editor window, in which you can fill in the table, search and select data, enter SQL queries and execute other operations:



    For further details about MetaTrader 5 operations with databases, please read the article entitled "SQLite: Native handling of SQL databases in MQL5".

  2. MetaEditor: Expanded support for multi-lingual projects. This update provides wider possibilities for working with Python scripts:

    • Now, such scripts can be created using the MQL5 Wizard, while you can instantly add required library dependencies in the code.
    • Special icons have been added in the navigator and the relevant syntax is available in the editor.
    • When running a script via MetaEditor, messages from the Python console (stdout, stderr) appear under the Errors section.




    Click "Compile" in the editor to run the script:





    To work with Python, do not forget to specify its path under the Settings \ Compilers section in MetaEditor. To enable the use of the MetaTrader 5 library, install it using the following command:
    pip install MetaTrader 5
    For Python integration details please read the relevant documentation.

  3. MQL5: Completely revised Python integration. The update involves many new functions and new command naming.

    New naming
    The existing commands have been renamed as follows:
    MT5Initialize       -> initialize
    MT5Shutdown         -> shutdown
    MT5TerminalInfo     -> terminal_info
    MT5Version          -> version
    MT5CopyRatesFrom    -> copy_rates_from
    MT5CopyRatesFromPos -> copy_rates_from_pos
    MT5CopyRatesRange   -> copy_rates_range
    MT5CopyTicksFrom    -> copy_ticks_from
    MT5CopyTicksRange   -> copy_tick_range

    New commands
    The list of supported commands has been expanded. Added trading functions, as well as functions for working with the trading history and for receiving financial symbol and current account data.

    • account_info() receives information about the current account. An analogue of AccountInfoInteger , AcountIndoDouble and AccountInfoString.
    • positions_total() receives the number of open positions. An analogue of PositionsTotal.
    • positions_get(symbol, ticket) receives open positions by symbol or ticket.
    • orders_total() receives the number of orders. An analogue of OrdersTotal.
    • orders_get(symbol, ticket) receives open orders by symbol or ticket.
    • history_orders_total(from, to) receives the number of orders in the specified historical time frame.
    • history_orders_get(from, to, position, ticket) receives orders from the specified historical time frame, by ticket or as filtered by position.
    • history_deals_total() receives the number of deals in the history. An analogue of HistoryDealsTotal.
    • history_deals_get(from, to, position, ticket) receives deals from the specified historical time frame, by ticket or as filtered by position.
    • symbol_info(symbol) receives information about a financial instrument. An analogue of SymbolInfoInteger, SymbolInfoDouble, SymbolInfoString.
    • symbol_info_tick(symbol) receives the last tick by symbol. An analogue of SymbolInfoTick.
    • symbol_select(symbol, enable) enables/disables a symbol in Market Watch. An analogue of SymbolSelect.
    • order_check(request) checks order margin. An analogue of OrderCheck.
    • order_send(request) sends an order to the server. An analogue of OrderSend.
    • order_calc_margin(action, symbol, volume, price) calculates margin for an order. An analogue of OrderCalcMargin.
    • order_calc_profit(action, symbol, volume, price_open, price_close) calculates profit. An analogue of OrderCalcProfit.

    Running Python scripts on charts
    Python scripts can be run directly on platform charts, similarly to regular MQL5 programs. These scripts are marked with special icons in the Navigator.



    Script messages will be displayed under the "Toolbox \ Experts" section. If a MetaTrader 5 library is used in the script, it can receive trading symbol and account data, as well as perform trading operations.

    Python scripts can be run on the same chart in parallel with other MQL5 scripts and Expert Advisors. To stop a script with a looped execution, remove it from the chart.

    Additional protection
    To enable additional account protection when using third-party Python libraries, you may use the "Disable automated trading via external Python API" option in terminal settings.




    Python scripts can only perform trading operations when this option is disabled.

  4. MQL5: Significantly accelerated re-launch of MQL5 programs and re-creation of custom indicators from MQL5 programs. In some cases, operations are performed 100 times faster.
  5. MQL5: Added functions for working with databases:

    DatabaseImport
    Imports data from a file to a table.
    long  DatabaseImport(
       int           database,          // database handle received in DatabaseOpen
       const string  table,             // table name to insert data to
       const string  filename,          // file name to import data from
       uint          flags,             // combination of flags
       const string  separator,         // data separator
       ulong         skip_rows,         // number of first rows to skip
       const string  skip_comments      // string of characters, which define comments
       );

    DatabaseExport
    Exports a table or an SQL query result to a CSV file. The file is created in UTF-8 encoding.
    long  DatabaseExport( 
       int           database,           // database handle received in DatabaseOpen 
       const string  table_or_sql,       // table name or SQL query
       const string  filename,           // CSV file name for data export
       uint          flags,              // combination of flags
       const string  separator           // data separator in the CSV file
       );

    DatabasePrint
    Prints the table or SQL query result to the Experts journal.
    long  DatabasePrint(
       int           database,          // database handle received in DatabaseOpen
       const string  table_or_sql,      // table or SQL query
       uint          flags              // combination of flags
       );

  6. MQL5: Added FileSelectDialog function, which calls the system dialog creating/opening a file or a folder.
    int  FileSelectDialog(
       string   caption,              // window title
       string   initial_dir,          // initial directory
       string   filter,               // extension filter
       uint     flags,                // combination of flags
       string&  filenames[],          // array with file names
       string   default_filename      // default file name
       );
    The new function enables the efficient user interaction with the MQL5 program.

  7. MQL5: New DEAL_FEE value in the ENUM_DEAL_PROPERTY_DOUBLE enumeration. It is used for a deal fee. The value indicates a separate commission type charged by the broker.

  8. Tester: Added functionality to specify custom trading account settings during strategy testing, such as trading limitations, margin settings and commission. The new functions provide extended capabilities for modeling various trading conditions.




    Common settings
    In this section, you can set the maximum number of open orders and positions, which can simultaneously exist on the account. Additionally, you can configure sessions during which the program is not allowed to trade.


    Margin
    The section allows configuration of margin reserving rules and position accounting systems to be used in testing:

    • Risk management — risk management model: OTC and exchange model, netting and hedging systems. For details please read the Documentation.
    • Margin call level — when this level is reached, the account switches to the Margin Call state.
    • Stop out level — when this level is reached, all orders are canceled and all trading positions are closed. These levels can be indicated in percentage and in money. If "in money' is selected, the levels are defined as the account's Equity value. If "In percent" is selected, the levels are defined as the account "Margin level" value (Funds/Margin*100).
    • Unrealized profit — accounting for the current floating profit/loss in the free margin:
      • Do not use unrealized profit/loss — do not include profit/loss of open positions in the calculation.
      • Use unrealized profit/loss — include open positions' profit/loss in the calculation.
      • Use unrealized profit — include only profit.
      • Use unrealized loss — include only loss.
    • Daily fixed profit — accounting for the client's daily fixed profit/loss in the free margin:
      • Use daily fixed profit/loss — include in the free margin profit and loss received during a trading day.
      • Use daily fixed loss — include only loss received during the trade day. During the day, the obtained profit is accumulated in the special account field ("Blocked"). At the end of the trading day, the accumulated profit is released (zeroed) and is added to the account balance (included in the free margin).
    • Release fixed profit at the end of day — this option becomes available only if the option "Use daily fixed loss" is selected. If it is enabled, the accumulated profit will be released (and thus included in the free margin) at the end of the day. Otherwise this profit amount will remain blocked.


    Commission
    This section provides control over commissions charged for all trading operations.

    • Commission may be single-level and multi-level, i.e. be equal regardless of the deal volume/turnover or can depend on their 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.
    • Different commissions 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.



  9. Tester: Optimized and accelerated work in the Market Scanner mode, during which multiple testing passes are run for all symbols available in the Market Watch.
  10. Tester: Deal or position size is now taken into account when calculating profit in pips. Previously, the calculation was only performed per one lot.
  11. Tester: Improved control over optimization results graph. The scroll option has been added for a zoomed optimization graph. Double-clicking on a graph point selects the corresponding result in the table of testing passes.
  12. MetaEditor: Added display of SQLite database files (*.db;*.sdb;*.sqlite;*.db3;*.s3db;*.sqlite3) in the Navigator.
  13. MetaEditor: Fixed project property saving errors.
  14. Updated documentation.

The new MetaTrader 5 version will be available through the LiveUpdate system.


Reason: