PositionsCount() returns 0 since MT5 build 4570

 

Hello Everyone,


Since build 4570 of MT5, I have had the problem that the function PositionsTotal() returns 0. In build 4410 this is not the case. I need the function to export data in an EA so I am looking for a solution.

This problem occurs on an account with a signal subscription.

The problem starts when I turn on “enable real-time signal subscription” in the options window under the signals tab.

When I turn this off the problem does not occur but that is not an option since I want to use the signal. 

What can I do to solve this problem?

Currently I am using build 4410 but I don't see that as a permanent solution. 


Any help is appreciated

 

Forum on trading, automated trading systems and testing trading strategies

MetaTrader 5 Platform update build 4570: Enhancements to the Web version and OpenBLAS integration in MQL5

MetaQuotes, 2024.09.13 11:36

MetaTrader 5 Client Terminal

  1. Terminal: Restricted access to MQL5 trading and history functions if the account is subscribed to a signal.

    When a signal subscription is detected on the account (regardless of whether copying is enabled in the current terminal), any MQL5 trading function calls are prohibited, including receiving open orders and positions, receiving history, and performing trading operations. A corresponding warning is logged in the journal:
    'XXX': signal subscription detected, trading and history access functions in MQL5 and Python disabled
    The restrictions also apply to Python trading functions: positions_total, positions_get, orders_total, orders_get, history_orders_total, history_orders_get, history_deals_total, history_deals_get, order_check, and order_send.

    If a signal subscription is canceled on the account or you connect to another account without a signal subscription, the restriction is lifted, and the following message is logged:
    'XXX': no signal subscription detected, trading and history access functions in MQL5 and Python enabled
    If the restriction is active on the account, MQL5 functions will return the following response codes:

    • OrderSend and OrderSendAsync return RET_REQUEST_AT_DISABLED_CLIENT
    • OrdersTotal and PositionsTotal return 0
    • PositionGetSymbol, PositionSelect, PositionSelectByTicket, and PositionGetTicket return ERR_MQLAPI_TRADE_POSITION_NOT_FOUND
    • OrderGetTicket and OrderSelect returns ERR_MQLAPI_TRADE_POSITION_NOT_FOUND
    • HistorySelect returns ERR_MQLAPI_TRADE_DEAL_NOT_FOUND
You can find out the parameters of all open positions through Object-functions.
Documentation on MQL5: Object Functions
Documentation on MQL5: Object Functions
  • www.mql5.com
This is the group of functions intended for working with graphic objects relating to any specified chart. The functions defining the properties of...
 

Thanks for the information guys.

I hesitate to work through the object functions. Correct operation of the EA then depends on certain settings of the chart.

Possibly I will log into the account on a separate terminal where the signal is off. Then I will have the data and functions I need available if I understand correctly.

 
Wim Rens #:

I hesitate to work through the object functions. Correct operation of the EA then depends on certain settings of the chart.

You can programmatically set the desired chart settings.

  • CHART_SHOW_TRADE_LEVELS  property of displaying trade levels on the chart (levels of open positions, Stop Loss, Take Profit and pending orders).
Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Examples of Working with the Chart
Documentation on MQL5: Constants, Enumerations and Structures / Chart Constants / Examples of Working with the Chart
  • www.mql5.com
This section contains examples of working with chart properties. One or two complete functions are displayed for each property. These functions...
 
fxsaber #:

You can programmatically set the desired chart settings.

Thank you for the suggestion.

I think it is indeed possible to solve it that way and I don't see a better option either.

The information I want to export is available in the objects(ticket id, position type, volume, price, symbol). I am going to have to do a lot of string operations here to retrieve the information though, hopefully this is not going to load the CPU too much.

The old way was easier anyway :-)