
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Are these the effects of yesterday's market storm? ;)
No :) I haven't used python in a while so I thought I'd convert one my my popular close-all scripts to python using pythonic abstractions.
I still cannot get the symbol of the chart that the script was dropped on. More importantly we should be able to get a list of all available symbols to the current account. Perhaps there is an undocumented function that I am unaware of, but as of right now I can only check if pairs and previously traded symbols exist and nothing else. This is a hack that I'd like to avoid by using something similar to MQL's SymbolsTotal and SymbolsName.
No :) I haven't used python in a while so I thought I'd convert one my my popular close-all scripts to python using pythonic abstractions.
I still cannot get the symbol of the chart that the script was dropped on. More importantly we should be able to get a list of all available symbols to the current account. Perhaps there is an undocumented function that I am unaware of, but as of right now I can only check if pairs and previously traded symbols exist and nothing else. This is a hack that I'd like to avoid by using something similar to MQL's SymbolsTotal and SymbolsName.
in the neighboring threading it`s discussed ... in russian (URL: https://www.mql5.com/ru/forum/306688/page56)
Small translation :) from me
Symbols_total (), symbols_get ([group = "EURUSD," USDGBP ", * RU *"]) are added in release 5.0.29.
it`s required to install the latest beta version of the Terminal.
look at threading, are many examples, etc, only russian ... + google translate ^)
in the neighboring threading it`s discussed ... in russian (URL: https://www.mql5.com/ru/forum/306688/page56)
Small translation :) from me
Symbols_total (), symbols_get ([group = "EURUSD," USDGBP ", * RU *"]) are added in release 5.0.29.
it`s required to install the latest beta version of the Terminal.
look at threading, are many examples, etc, only russian ... + google translate ^)
I don't speak Russian so would it be possible for you to communicate the following to that thread on my behalf?
The symbols_get function should return a generator of SymbolInfo named tuples. A call to symbols_get without args should return all symbols available in the terminal. The function should take a callback which would be passed in a SymbolInfo namedtuple to be processed using the filter function. Here are some examples.
I don't speak Russian so would it be possible for you to communicate the following to that thread on my behalf?
OK, no problem ...
You can write to this thread, many speak English and the developers are reading the exact same thread.
No :) I haven't used python in a while so I thought I'd convert one my my popular close-all scripts to python using pythonic abstractions.
I still cannot get the symbol of the chart that the script was dropped on. More importantly we should be able to get a list of all available symbols to the current account. Perhaps there is an undocumented function that I am unaware of, but as of right now I can only check if pairs and previously traded symbols exist and nothing else. This is a hack that I'd like to avoid by using something similar to MQL's SymbolsTotal and SymbolsName.
With version 5.0.29 and latest beta version of Terminal, you can use symbols_get() method to retrieve all available symbols.
Im dorry for the delkay in reply. Im running MT5 on linux (Fedora) with a wine installation. The error I get is:
ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)
ERROR: No matching distribution found for MetaTrader5
What is the error you are getting?
Im dorry for the delkay in reply. Im running MT5 on linux (Fedora) with a wine installation. The error I get is:
ERROR: Could not find a version that satisfies the requirement MetaTrader5 (from versions: none)
ERROR: No matching distribution found for MetaTrader5
Uhhh ... you use of MT5 (Wine) + python (Wine)?!
cool ... I could not get to make such a configuration :(
Is it possible to send a request to set a stop loss on an existing order?
I have a code that works in my python ea, which can set and open trades. however I need to know the syntax for mt5.Buy(), mt5.Sell(), and what values they accept. for example how can i set a stop loss and take profit value when sending a buy? or a sell?
and how can I update the order? (i can't send a request to update a stoploss) i get an invalid request 10016 error
my ea actually works to connect buy and sell but i don't see any examples or documentation for buy and sell.
my buy code (i save the order number to a variable called "ticket" so i can use it later to see if the order was successful)
r = mt5.Buy(symbol, lot)
Is it possible to send a request to set a stop loss on an existing order?
I have a code that works in my python ea, which can set and open trades. however I need to know the syntax for mt5.Buy(), mt5.Sell(), and what values they accept. for example how can i set a stop loss and take profit value when sending a buy? or a sell?
and how can I update the order? (i can't send a request to update a stoploss) i get an invalid request 10016 error
my ea actually works to connect buy and sell but i don't see any examples or documentation for buy and sell.
my buy code (i save the order number to a variable called "ticket" so i can use it later to see if the order was successful)
r = mt5.Buy(symbol, lot)
You can set the tp/sl when you send the order as well as modifying it. Here is a quick example.
I don't speak Russian so would it be possible for you to communicate the following to that thread on my behalf?
The symbols_get function should return a generator of SymbolInfo named tuples. A call to symbols_get without args should return all symbols available in the terminal. The function should take a callback which would be passed in a SymbolInfo namedtuple to be processed using the filter function. Here are some examples.
See sample in symbols_get please
Example:
import MetaTrader5 as mt5
# display data on the MetaTrader 5 package
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# establish connection to the MetaTrader 5 terminal
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
# get all symbols
symbols=mt5.symbols_get()
print('Symbols: ', len(symbols))
count=0
# display the first five ones
for s in symbols:
count+=1
print("{}. {}".format(count,s.name))
if count==5: break
print()
# get symbols containing RU in their names
ru_symbols=mt5.symbols_get("*RU*")
print('len(*RU*): ', len(ru_symbols))
for s in ru_symbols:
print(s.name)
print()
# get symbols whose names do not contain USD, EUR, JPY and GBP
group_symbols=mt5.symbols_get(group="*,!*USD*,!*EUR*,!*JPY*,!*GBP*")
print('len(*,!*USD*,!*EUR*,!*JPY*,!*GBP*):', len(group_symbols))
for s in group_symbols:
print(s.name,":",s)
# shut down connection to the MetaTrader 5 terminal
mt5.shutdown()
Result:
MetaTrader5 package author: MetaQuotes Software Corp.
MetaTrader5 package version: 5.0.29
Symbols: 84
1. EURUSD
2. GBPUSD
3. USDCHF
4. USDJPY
5. USDCNH
len(*RU*): 8
EURUSD
USDRUB
USDRUR
EURRUR
EURRUB
FORTS.RUB.M5
EURUSD_T20
EURUSD4
len(*,!*USD*,!*EUR*,!*JPY*,!*GBP*): 13
AUDCAD : SymbolInfo(custom=False, chart_mode=0, select=True, visible=True, session_deals=0, session_buy_orders=0, session...
AUDCHF : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
AUDNZD : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
CADCHF : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
NZDCAD : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
NZDCHF : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
NZDSGD : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
CADMXN : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
CHFMXN : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
NZDMXN : SymbolInfo(custom=False, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, sessi...
FORTS.RTS.M5 : SymbolInfo(custom=True, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, ...
FORTS.RUB.M5 : SymbolInfo(custom=True, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, ...
FOREX.CHF.M5 : SymbolInfo(custom=True, chart_mode=0, select=False, visible=False, session_deals=0, session_buy_orders=0, ...