• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 7:00pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 7:00pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Python Trader code and skills sharing 54 replies

embedding python 19 replies

Monty python and the holy grail 4 replies

Upcoming MetaTrader5 with MQL5 3 replies

Python or Perl? 17 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 9
Attachments: Metatrader5 and Python
Exit Attachments

Metatrader5 and Python

  • Last Post
  •  
  • 1 2Page 3 4
  • 1 2Page 3 4
  •  
  • Post #41
  • Quote
  • Jul 24, 2020 1:50pm Jul 24, 2020 1:50pm
  •  kasinath
  • | Joined May 2020 | Status: Member | 68 Posts
Quoting rudy5
Disliked
Something I’ve been doing which might help people is to have plotly auto save images of my entry triggers. https://plotly.com/python/static-image-export/
Ignored
Nice! This certainly looks promising. Thanks for sharing!
  • Post #42
  • Quote
  • Aug 13, 2020 9:51pm Aug 13, 2020 9:51pm
  •  rudy5
  • | Joined Nov 2014 | Status: Member | 571 Posts
New backtester:
https://www.reddit.com/r/algotrading...tm_medium=mweb


mass data:
https://www.kaggle.com/qks1lver/amex...tock-histories
3
  • Post #43
  • Quote
  • Aug 27, 2020 5:41pm Aug 27, 2020 5:41pm
  •  bralgo
  • | Joined Jun 2016 | Status: Member | 10 Posts
Please assist, I am having challenge when downloading TIMEFRAME_M1 in python. I can only download prices for TIMEFRAME_M5 going upwards.This started when I recently updated MT5, now i get the 'time error' in the python terminall. Please have a look at my code below.
Inserted Code
import numpy as np
import pandas as pd
from datetime import datetime
import MetaTrader5 as mt5
import pytz
# display data on the MetaTrader 5 package
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# establish connection to MetaTrader 5 terminal
if not mt5.initialize():
    print("initialize() failed, error code =",mt5.last_error())
    
# set time zone to UTC
timezone = pytz.timezone("Etc/UTC")
#create 'datetime' objects in UTC time zone to avoid the implementation of a local time zone offset
utc_from = datetime(2020, 1, 1, tzinfo=timezone)
utc_to = datetime(2020, 1, 11, hour = 13, tzinfo=timezone)
ratesUJ = mt5.copy_rates_range("USDJPY",  mt5.TIMEFRAME_M1, utc_from, utc_to)
#ratesUJ = mt5.copy_rates_range("USDJPY",  mt5.TIMEFRAME_M5, utc_from, utc_to)
# shut down connection to the MetaTrader 5 terminal
mt5.shutdown()
# create DataFrame out of the obtained data
ratesUJ =  pd.DataFrame(ratesUJ)
print(ratesUJ.head()
  • Post #44
  • Quote
  • Sep 1, 2020 8:31am Sep 1, 2020 8:31am
  •  Nicholishen
  • Joined Jul 2005 | Status: zzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzz | 1,289 Posts
Quoting bralgo
Disliked
Please assist, I am having challenge when downloading TIMEFRAME_M1 in python. I can only download prices for TIMEFRAME_M5 going upwards.This started when I recently updated MT5, now i get the 'time error' in the python terminall. Please have a look at my code below. import numpy as np import pandas as pd from datetime import datetime import MetaTrader5 as mt5 import pytz # display data on the MetaTrader 5 package print("MetaTrader5 package author: ",mt5.__author__) print("MetaTrader5 package version: ",mt5.__version__) # establish connection to...
Ignored
Sounds like a weird bug in your platform. Try deleting the history. Other than that you should debug using the last_error function.
1
  • Post #45
  • Quote
  • Sep 6, 2020 2:54am Sep 6, 2020 2:54am
  •  fxke62
  • | Joined Jul 2019 | Status: Member | 52 Posts
Advice please! I am an (5yrs) experienced (database/filemaker) developer. I have just started learning Python. How many months would it take me
before I can

A. download historic data from MT5
B. program bots in python to trade on MT5?

Assume I learn fast and spend 1 hour a day, 6 days a week on learning Python.
Thanks for your ideas!
  • Post #46
  • Quote
  • Sep 13, 2020 10:57am Sep 13, 2020 10:57am
  •  bralgo
  • | Joined Jun 2016 | Status: Member | 10 Posts
Quoting fxke62
Disliked
Advice please! I am an (5yrs) experienced (database/filemaker) developer. I have just started learning Python. How many months would it take me before I can A. download historic data from MT5 B. program bots in python to trade on MT5? Assume I learn fast and spend 1 hour a day, 6 days a week on learning Python. Thanks for your ideas!
Ignored
A: https://www.mql5.com/en/docs/integra...on_metatrader5
B: https://www.mql5.com/en/forum/306742
  • Post #47
  • Quote
  • Sep 13, 2020 10:02pm Sep 13, 2020 10:02pm
  •  fxke62
  • | Joined Jul 2019 | Status: Member | 52 Posts
Thanks Bralgo for the useful links, I have read a lot already.

However my question still stands. Copying scripts makes me a monkey that doesn't know what he is doing.
  • Post #48
  • Quote
  • Sep 25, 2020 1:35am Sep 25, 2020 1:35am
  •  gellowmellow
  • | Joined Apr 2020 | Status: Member | 562 Posts
Quoting fxke62
Disliked
Thanks Bralgo for the useful links, I have read a lot already. However my question still stands. Copying scripts makes me a monkey that doesn't know what he is doing.
Ignored
If you're a seasoned coder (not even necessarily Python), should take you even less than a day.
But the hard part is the strategy - and backtesting this strategy.
What's the use of a trading bot if it can't make money eh? Lol
Peace is more valuable than success.
LifeDrifts v1 [automated] All Time Return: -8.5%
  • Post #49
  • Quote
  • Sep 25, 2020 2:42am Sep 25, 2020 2:42am
  •  fxke62
  • | Joined Jul 2019 | Status: Member | 52 Posts
Thanks @gellowmellow. That is good news then, especially since I am using my own database (with price data) to back-test.
  • Post #50
  • Quote
  • Sep 25, 2020 6:58pm Sep 25, 2020 6:58pm
  •  loopd
  • | Joined Dec 2018 | Status: Member | 30 Posts
Just to be clear the MT5 API with python only work in live trading, and will not work in MT5 built in strat tester. so you have to write your own back test engine right?
Thx
  • Post #51
  • Quote
  • Sep 26, 2020 8:17pm Sep 26, 2020 8:17pm
  •  rudy5
  • | Joined Nov 2014 | Status: Member | 571 Posts
Yaw
  • Post #52
  • Quote
  • Sep 27, 2020 2:24am Sep 27, 2020 2:24am
  •  fxke62
  • | Joined Jul 2019 | Status: Member | 52 Posts
Yes that is exact;y my plan (in execution now).
  • Post #53
  • Quote
  • Sep 27, 2020 9:19pm Sep 27, 2020 9:19pm
  •  loopd
  • | Joined Dec 2018 | Status: Member | 30 Posts
Quoting fxke62
Disliked
Yes that is exact;y my plan (in execution now).
Ignored
isn't it more convenient to be able to connect python with MT5 backtest engine since they already have such a powerful one.
  • Post #54
  • Quote
  • Sep 27, 2020 11:05pm Sep 27, 2020 11:05pm
  •  fxke62
  • | Joined Jul 2019 | Status: Member | 52 Posts
Quoting loopd
Disliked
Just to be clear the MT5 API with python only work in live trading, and will not work in MT5 built in strat tester. so you have to write your own back test engine right? Thx
Ignored
IF that was possible, yes for those good with python (i am just starting). but i thought i understood from your post as of now it is not possible?
  • Post #55
  • Quote
  • Sep 28, 2020 9:25am Sep 28, 2020 9:25am
  •  loopd
  • | Joined Dec 2018 | Status: Member | 30 Posts
Quoting fxke62
Disliked
{quote} IF that was possible, yes for those good with python (i am just starting). but i thought i understood from your post as of now it is not possible?
Ignored
that is my understanding
  • Post #56
  • Quote
  • Edited at 1:51pm Nov 28, 2020 1:32pm | Edited at 1:51pm
  •  rudy5
  • | Joined Nov 2014 | Status: Member | 571 Posts
hey could someone help me out... I moved my program over to an older win7 machine to use as a server and, while I can get the basic MetaTrader5 from pypi installed and working, pymt5adapter won't work.

I got python on my machine through anaconda and its the only version of python that exists. I figured maybe I had a path problem but then, why would the MetaTrader5 package work but not the pymt5adapter package?

both were installed via pip. When I request symbol info thru MetaTrader5 I get the data, but pymt5 returns None
  • Post #57
  • Quote
  • Dec 4, 2020 12:34am Dec 4, 2020 12:34am
  •  rudy5
  • | Joined Nov 2014 | Status: Member | 571 Posts
also, got the strangest error I've yet seen in python. a more experienced friend of mine said it's likely an encoding problem but mt5 doesn't tell me where in the program this error is happening
Attached Image (click to enlarge)
Click to Enlarge

Name: Screen Shot 2020-12-03 at 11.00.47 PM.png
Size: 17 KB
  • Post #58
  • Quote
  • Dec 8, 2020 4:19am Dec 8, 2020 4:19am
  •  takepip
  • | Joined Dec 2020 | Status: Junior Member | 6 Posts
Quoting kasinath
Disliked
So, ever since i discovered TA-Lib and saw @nicholisen's endorsements, I'm exploring using python to build WORA trading robots. Now, in the short term, I would still use MT5 and/or MT4, but I am ready to get on the python train and be rid of MQL. Like, Forever. With that said, I hear that if i were looking to adopt Python, MT backtesting may not be as straightforward, or not possible. Is there a way around that? I'd imagine it should be possible to write a shell EA in MQL, whose sole purpose is to take inputs and send them over TCP/IP to a python...
Ignored
I have a questions about TA-Lib. How do you use TA-Lib for live trading? It takes entire historical data array and calculate corresponding indicator values. What do you do when you receive a new tick or new candle? Do you have to pass the entire historical data array into TA-Lib and let it recalculate everything again? That seems very inefficient. Is that how it's supposed to work or am I missing something?

Custom framework may be easy to write if you are good at programming but testing can be a challenge. If you are familiar with MT4/MT5 you may be able to test your framework against output of Metatrader. However you may not know the logic Metatrader uses when your output is different from MT5's.
  • Post #59
  • Quote
  • Feb 13, 2021 2:08pm Feb 13, 2021 2:08pm
  •  rudy5
  • | Joined Nov 2014 | Status: Member | 571 Posts
Just an FYI for anyone potentially reading this in the future and wondering about FXCMs python wrapper. I've been using it and while it works, it's kinda weird and has some limitations. Nowhere near as nice as accessing a local MT5 platform. I'm actually opting to run my program on an HDD with windows just to have access to MT5 rather than use FXCM on a ubuntu OS which was on an SSD
  • Post #60
  • Quote
  • Feb 15, 2021 5:48pm Feb 15, 2021 5:48pm
  •  rudy5
  • | Joined Nov 2014 | Status: Member | 571 Posts
Has anyone written any indicators that get plotted on an mt5 chart?
  • Platform Tech
  • /
  • Metatrader5 and Python
  • Reply to Thread
    • 1 2Page 3 4
    • 1 2Page 3 4
0 traders viewing now
  • More
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021