Python in algorithmic trading - page 7

 

MetaTrader 5 for Python setup



MetaTrader 5 for Python setup

The video tutorial covers the process of installing MetaTrader 5 for Python which involves entering "pip install MetaTrader5" in the Anaconda Prompt and verifying the installation by running the MT5Initialize() function from the MT5 package in Python.

MetaTrader 5 for Python setup
MetaTrader 5 for Python setup
  • 2019.04.21
  • www.youtube.com
MetaTrader 5 계좌만들기 : https://www.forextime.com/?form=JbbrANACONDA : https://www.youtube.com/watch?v=YGkps5nqpKk- in real, I prefer the Visual Studio Python...
 

Building a web application using Python and MetaTrader 5 with Streamlit




Building a web application using Python and Metatrader 5 with Streamlit

This video demonstrates how to create a real-time chart using Python, Streamlit, and MetaTrader 5 that displays currency exchange rates and offers zoom and timeframe options. The presenter uses Pandas for importing data frames and Plotly to plot data, adding functions to calculate moving averages and Relative Strength Index. The video includes threading to handle zooming and keyboard shortcuts for interactivity. The presenter concludes the video by explaining the code's different functions and adding functionality to draw objects on charts, sharing the code in the app's description. The tutorial offers beginners a simple introduction to building real-time financial charts.

  • 00:00:00 In this section, the video's creator showcases a real-time chart built using MetaTrader 5, Python, and Streamlit. The chart displays currency exchange rates and offers features to zoom in, zoom out, and switch between timeframes. The Python code uses the Streamlit and MetaTrader 5 libraries, along with Pandas for importing data frames and Plotly for graphing. The chart includes functions to calculate the moving average and Relative Strength Index with adjustable parameters for users. The creator also includes threading to handle zooming and keyboard shortcuts for user interactivity. Overall, the tutorial offers a beginner-friendly introduction to using these libraries for building real-time financial charts.

  • 00:05:00 you want to build a web application using Python and MetaTrader 5 with Streamlit, you will need to call specific functions to provide the necessary data. To get the symbols, you can use the "metatrader" function to extract their names and then return them in a dictionary format. The set package configuration function allows you to customize the layout of the web application, such as the window size and title. Additionally, in order to calculate the lsi (relative strength index), you must provide the function with the necessary data and parameters, such as the data frame and rsi value, which can then be plotted.

  • 00:10:00 In this section, the speaker explains how he created global variables and added the LSI calculation to the data frame, and appended the trace so that the RSI values can be shown on the chart. He also shows how he created the infinite loop function, which updates the chart every second, using the time frame, symbol, bars, moving average, and LSI values. The time frame is obtained from a dictionary and the bars are obtained using the mt5.copy_rates_from_pos() function. The chart is not an image but an animation that is constantly being updated every second.

  • 00:15:00 In this section, the presenter explains how to convert bars data frame to be reduced later on and how to convert time into seconds for better readability. The section also covers using a scatter chart and how to calculate the moving average to plot it to the chart. The presenter updates the figure layout with a fixed range and paper color to have the chart fixed in place and to better present the data to the user.

  • 00:20:00 In this section, the speaker explains how they made adjustments to the size of the window and the x-axis to eliminate gaps in the daily chart. They also add a horizontal line of the last price using a simple
    line of code. The speaker then demonstrates the on press key function which shrinks or grows the chart when the user presses the minus or plus key. The code includes multiple functions and placeholders to keep the application simple and easy to navigate.

  • 00:25:00 In this section, the speaker explains the code for initializing the connection between Metatrader5 and the chart, and the use of a keyboard listener thread to adjust the size of the chart using the plus and minus keys. They also discuss the use of the `st.title` function and the creation of two columns for the sliders and options through the `st.connect` function. The speaker explains the use of a placeholder for column one and the selection of a moving average through the `sd.selectbox` function. They also mention the availability of options for choosing the stock symbol or pair, as well as the time frame.

  • 00:30:00 In this section, the YouTuber concludes the demonstration of building a web application using Python and MetaTrader 5 with Streamlit. They explained that the app displayed information about trading signals and added functionality to draw objects on the charts. They also pointed out the different functions and their purposes in the code, ending with sharing the code in the app's description. The YouTuber thanked their viewers for watching and concluded the video.
Building a web application using Python and Metatrader 5 with Streamlit
Building a web application using Python and Metatrader 5 with Streamlit
  • 2022.07.23
  • www.youtube.com
This is web application made with streamlit and metatrader 5 .************The code is here : https://github.com/azario0/metatrader5-streamlit************My l...
 

PYTHON SYNTHETIC INDEX TRADING BOT!! - RECEIVING CANDLE DATA FROM MetaTrader 5



PYTHON SYNTHETIC INDEX TRADING BOT!! - RECEIVING CANDLE DATA FROM MetaTrader 5

The video tutorial explains how to create a Python trading bot that receives candle data from MetaTrader 5 (MT5). The presenter covers the process step-by-step, including configuring MT5, creating a class for the bot, initializing variables, creating threads, and defining trading strategy with simple take profit and stop loss parameters. The presenter also provides instructions on handling errors and debugging the code, and concludes the video by highlighting the simplicity of the process and mentioning an upcoming course on the topic. The tutorial is insightful and beginner-friendly, making it a great resource for anyone interested in creating a Python trading bot.

  • 00:00:00 In this section of the video, the presenter shows how to create an index trading bot with Python by explaining the steps involved in the process. The first step is to configure the MetaTrader 5 platform by enabling algorithmic trading and allowing web requests for the local host. After that, the presenter opens Visual Studio Code and starts coding by creating a class for the bot with a constructor that receives parameters for the lot edge, time period, and market. The bot will work with threads that share information through a dictionary, so the presenter initializes a list of threads and a dictionary for storing the shared data. Finally, an event is created to stop the threads. The presenter provides further information and explanations in the GitHub repository.

  • 00:05:00 In this section, the presenter initializes all the necessary items such as class variables, constants, queues, dictionaries, and threads to allow the trading bot to share data between threads. The presenter also declares methods for the bot to start and kill the threads. The kill thread function sets the value of the peel variable to 'kill' and then calls the join function to stop the threads safely. Finally, the presenter creates a wait function that enables the user to stop the bot by pressing enter.

  • 00:10:00 In this section of the video, the speaker explains that they will create a Python program to receive candle data from MetaTrader 5 using sockets. They begin by creating a file called candles.py and importing the necessary libraries like socket and json to send and receive data through sockets. They also define the address and port to be used for the socket connection. The speaker then proceeds to create a function to initialize the socket connection using server and client sockets. They demonstrate how to bind the socket to the specified address and port and listen for incoming connections. The function then accepts connections and prints out the client address.

  • 00:15:00 In this section, the YouTuber explains how to create the function that will take candle information by calling the "thread_candles" function. It starts by creating a variable called "message" to receive information from MetaTrader5. Then, the socket is started, and a main loop is created that will work until the user presses enter, at which point the pill to kill is set. The loop starts by taking the message from the socket from the connection and decoding it. The code checks if the message can be printed, and if it can, it will print it. After showing how to create the main file, the YouTuber moves on to explaining how to create a client inside MT5, but emphasizes they won't go deep since it's not an MT5 tutorial.

  • 00:20:00 In this section, the presenter provides a step-by-step guide on how to copy the code from GitHub and use it to create a Python trading bot that receives candle data from MT5. The presenter explains that the code uses tokens to send information on every tick and creates a string that contains the JSON format for each candle's open and close prices. To transform the string into a dictionary, the presenter suggests using the json load function. The presenter also demonstrates how to start and stop the bot and the client, and how to delete the bot from the expert advisor menu.

  • 00:25:00 In this section, the video tutorial walks through updating a dictionary with data received from MT5 and creating an orders thread. The updated dictionary is sent using the self.data function, which converts the data into the correct format. The tutorial includes defining macros for the bot, such as the number of candles between operations and stop loss parameters. The orders thread function receives the stop event and trading data, and creates a basic trading strategy with a simple take profit and stop loss. The tutorial also includes closing the connection and server socket, followed by testing the bot with sample code.

  • 00:30:00 In this section, the YouTuber discusses the necessary steps to receive candle data from MT5 and use it to open operations based on certain criteria. The first step is to declare a variable called last operation time and set its initial value to zero, which will be used later to track when an operation was opened. Then, an epoch is declared using the datetime function which we will later use to convert the current time into seconds. Next, we wait for the candle thread to start in order to prevent errors. Once it has finished, we go into a loop where we check if the conditions for opening an operation are met. If the previous candle is a boom (close > open) and the current time is greater than the last operation time plus the trading data time period, an operation is opened. The last operation time is updated and the open position function is called. Finally, the trading data (including market and lot size) is defined and passed as an argument to the open position function.

  • 00:35:00 In this section, the creator explains how to send cell operation using MT5, and gives a tutorial on how to execute an open position function. The user needs to input the market as a string, the lotex as a float and type operation. This function helps in defining the stop loss and take profit variables which are defined by taking the current price minus the stop loss value, and adding the take profit value to the current price. The creator recommends using cell candle and trading data to test and debug the code. Finally, the creator provides an example of when the function is run, and the orders are traded.

  • 00:40:00 In this section, the tutorial focuses on debugging errors. The step-by-step process of debugging is shown, starting from the error message displayed to googling to find a solution. The specific error here is invalid order filling type, which is dependent upon the broker being used. The solution is to try all three order filling types listed and see which one works for your broker. Once the error is fixed, the tutorial moves on to opening a position successfully.

  • 00:45:00 In this section, the speaker concludes the video by providing a brief overview of the Python synthetic index trading bot, highlighting how easily it can be created. He also mentions that he will be creating a course on this topic, which will be very comprehensive and reasonably priced compared to similar courses. He encourages viewers to like, share, and subscribe to his channel, and to reach out to him with any questions.
PYTHON SYNTHETIC INDEX TRADING BOT!! - RECEIVING CANDLE DATA FROM MT5
PYTHON SYNTHETIC INDEX TRADING BOT!! - RECEIVING CANDLE DATA FROM MT5
  • 2022.06.29
  • www.youtube.com
YOU MUST INSTALL THE MT5 LIBRARY FOR PYTHON:pip install MetaTrader5In this video I'm going to teach you how to create a PYTHON TRADING BOT that uses MT5 and ...
 

How to import stock price data from MetaTrader 5 into Python?



How to import stock price data from MetaTrader 5 into Python?

In this YouTube video, different methods to import stock price data from MetaTrader 5 into Python are explained. The methods include importing necessary libraries, setting the desired time frame and time zone, defining a function called "get data," manipulating the resulting data frame, using the tqtndm package, creating a rates frame, and utilizing two data frames to retrieve prices and date/time information. The speaker suggests putting the loops into a function to make the code cleaner, and using these methods, users can easily import data for numerous symbols without much difficulty.

  • 00:00:00 In this section, the speaker explains how to import stock price data from MetaTrader5 into Python. The first step is to import all the necessary libraries, including pandas, pytz, datetime, tqdm, and MetaTrader5. Then, the speaker initializes MetaTrader5 and sets the desired time zone and time frame. The speaker defines a function called "get data" that requires the symbol, the number of candles needed, and the time frame. The function returns the desired data, and the speaker explains what each input and output does in the function.

  • 00:05:00 In this section, the speaker explains a function used to import stock price data from MetaTrader5 into Python. The function takes in a symbol, a time frame, and a date, and returns a data frame containing the requested data. The speaker goes through steps to manipulate the resulting data frame, including converting the time column to daytime and dropping unnecessary columns. Additionally, the use of a for loop is suggested to make it easier to call data for multiple assets.

  • 00:10:00 In this section, the speaker explains how to import stock price data from MetaTrader5 into Python using the tqtndm package. They use the try function and accept function to call a rates function previously defined that takes in the symbol and the number of days set to 400. The returned data is appended to a dictionary, and any not available data is dropped. The speaker suggests putting the loop into a function to make the code cleaner. Overall, the process involves creating a rates frame, appending the data to a dictionary, and then running the script.

  • 00:15:00 In this section, the speaker explains that with the use of two data frames, users can easily import stock price data from metatrader5 to Python by retrieving the prices and date/time information. This method can be used for numerous symbols without much difficulty.
How to import stock price data from metatrader5 into python?
How to import stock price data from metatrader5 into python?
  • 2022.04.10
  • www.youtube.com
Using MetaTrader5 module in python to import data from metatrader to python and turn it into a dataframe to use in your strategy backtesting .
 

Online Trading by Python in MetaTrader 5 + get data from MQL5



Online Trading by Python in MetaTrader 5 + get data from MQL5

The tutorial demonstrates how to download a dataset from MetaTrader and conduct online trading deals using Python. The instructor imports the MetaTrader5, pandas, and datetime libraries, specifies the asset and timeframe for the dataset, and downloads the last hundred data points. They explain how to manage a position in MetaTrader5 by setting stop loss, take profit, and using the GTC command for a specified duration. While the section provides a basic understanding of the different commands required to manage a position, it's unclear what the overall trading strategy being employed is.

  • 00:00:00 In this section of the tutorial, the instructor demonstrates downloading a dataset from MetaTrader 5 and conducting simple online trading deals using Python. The MetaTrader5 library is imported, and the software shortcut path is addressed to Python. The pandas and datetime libraries are also imported, and the current time is used to specify the time of the last data in the dataset. The symbol key of the desired asset is written, and the timeframe (daily timeframe in this case) is selected for the dataset. The last one hundred data points are downloaded, and a format command is used to store the data in the user's personal system. Online trading is carried out by determining the assets and volume of the transaction, defining the unit of price as a pip, and using either ask or bid price depending on the position entered.

  • 00:05:00 In this section, the video explains how to set stop loss and take profit for a position using Python commands in MetaTrader 5. It also shows how to close the position by specifying the position ticket number. The GTC command is explained for keeping a transaction active for a specified duration. The video also shows an example of a USDJPY transaction with an active stop loss and take profit. Overall, this section provides a basic understanding of the different commands required to manage a position in MetaTrader 5 through Python.

  • 00:10:00 In this section, we learn that the long position was successfully closed. Unfortunately, without further context, it is unclear what the long position refers to or what the overall trading strategy being employed is.
online trading by python in MetaTrader5 + get data from mql5
online trading by python in MetaTrader5 + get data from mql5
  • 2022.04.19
  • www.youtube.com
https://github.com/Hesamtps/online-trading-by-python-in-MetaTrader5-get-data-from-mql5
 

Python MetaTrader 5 Copy Trade



Python MetaTrader 5 Copy Trade

This application can copy trade from MetaTrader 5 to another MetaTrader 5 controlled by web dashboard that also can control who can copy your trade, set pair/ticker, set volume, stop loss, and take profit each one of your copier signal.
Time tolerance for copy is 5 seconds, if more than 5 secs signal will not copied, windows cmd sometimes stuck, recommended to use another terminal application on windows.

Q & A
-----------------------------------
Q : Can run using MT4
A : No, MT4 doesn't support python

Q : Can run on linux?
A : No, actually mt5 is designed for windows, if running on mac or linux it's only run using like windows emulator, or something like that to force run windows application running on mac or linux

Q : Is there a guarantee that the signal will be copied?
A : the success or failure of the signal to be copied depends on various factors, the most frequently your vps condition, can handle connection from master or clients, unstable client connection, script delay, terminal, hangs, etc.

If you have any problems like freezing command prompt when running python script, please go to https://stackoverflow.com/questions/591047/command-line-windows-hanging-in-rdp-windows

Scripts
------------
create virtual environment :
python -m venv .venv

activate virtual environment :
.venv/Scripts/activate

install requirements library :
pip install -r requirements.txt

running master script :
python master.py

running slave script :
python trade.py

Python MT5 Copy Trade
Python MT5 Copy Trade
  • 2022.06.15
  • www.youtube.com
This application can copy trade from MT5 to another MT5 controlled by web dashboard that also can control who can copy your trade, set pair/ticker, set volum...
 

Python & MetaTrader Back Testing Systems | Developing & Test Trading ML Strategies



Python & Metatrader Back Testing Systems | Developing & Test Trading ML Strategies

The video discusses the development of a stable backtesting platform to evaluate multiple trading strategies and employ machine learning for forex trading. The speaker demonstrates how to create a new backtesting platform using MetaTrader 5 that interfaces with brokers to extract input data. They also explain how to code an expert advisor to extract data, process it using Python strategies, and then initiate trades based on predetermined parameters. The video also shows how to generate label data and extract features for building and training machine learning algorithms. Finally, the speaker discusses several algorithms used for backtesting, with random forest identified as the most accurate. Overall, the backtesting system provided reliable and efficient results, with a performance of 96%, and future work includes integrating machine learning algorithms into live trading environments.

  • 00:00:00 In this section, the speaker introduces the concept of forex trading and why it has become so popular with institutions, governments, multinational corporations, and individual investors. The market is open 24 hours a day from Monday to Friday, making it accessible to anyone. One of the reasons for its popularity is the immense profit potential. However, accurate prediction of forex exchange direction is important. To that end, the speaker's objective was to create a stable backtesting platform to evaluate multiple trading strategies, determine which currency pairs and timeframes performed best, and use machine learning to improve predictions. The speaker also mentions previous research that used support vector machines and artificial neural networks for prediction.

  • 00:05:00 In this section, the speaker discusses the approach to developing a backtesting platform for algorithm training and testing, which is the first step in developing machine learning algorithms. They examine the available backtesting platforms, such as MK Backtesting, but ultimately decide to create a new one that seamlessly integrates with existing Python strategies and meets the criteria for data consistency and integrity. The new platform relies on the industry-standard MetaTrader 5 platform, which interfaces with brokers to extract input data for the backtesting platform. The backtesting platform uses a set of parameters like stop loss and take profit to evaluate data and generate output files based on the signal generated by trading strategies, like the Trading Strategy Class. Overall, the approach involves preparing level data, developing a backtesting platform, and then building a machine learning algorithm based on the prepared data.

  • 00:10:00 In this section, the speaker describes how an expert advisor is coded to extend data from MetaTrader 5 on a live trading basis every time a new candle is generated. The expert advisor extracts data from MetaTrader 5 and writes it to an external spreadsheet file, which is then read by a Python engine to process it using different strategies to get a trading signal. The signal is then written to an action file, which is read by the expert advisor, and it then initiates trades into the MetaTrader 5 environment. The trading environment can do live trading by executing trades based on determined take profit and stop loss margins, and the expert advisor modifies and closes trades based on various parameters.

  • 00:15:00 In this section, the speaker explains the process of backtesting and generating a report in the MetaTrader platform. They show how to adjust the speed of the backtesting and import the necessary strategies to make predictions. They then discuss the different functions of the program, including the action writer, which handles housekeeping tasks like creating and saving output files. Finally, they demonstrate the report produced by the backtesting, which includes a summary of all the trading done along with details about the currency pair, time frame, and period.

  • 00:20:00 In this section, the video explains the use of a backtesting platform designed for creating label data and feature extraction for building and training ML algorithms for trading. This platform simplifies the process by taking the whole period of extracted data and generating the signals and indicators necessary for trading, then initiating and tracking the trades to get the real results. Using this platform, the video shows how to generate label data that represents the true outcome of the trade and the various features extracted from the data, such as RSI, TSI, and Stochastic. By creating more balanced data, this platform can generate more reliable machine learning algorithms for trading.

  • 00:25:00 In this section, the speaker discusses the different machine learning algorithms used for backtesting, including support vector machine, logistic regression, xgboost, MLP, and random forest. The accuracy of each algorithm is recorded and analyzed, and the speaker identifies random forest as the most accurate with 96% accuracy. The data is also labeled and tracked to create a spreadsheet file for later use. Overall, the process of backtesting with these algorithms is quick and efficient.

  • 00:30:00 In this section, the speaker summarizes the results of the backtesting system and the development of trading ML strategies using technical indicators and machine learning algorithms. The stable backtesting platform provided reliable and efficient results, with a performance of 96% compared to the benchmark strategy SMAEMA, which only had a 25% performance. The backtesting platform was capable of automated trading without manual intervention required. Future work includes the integration of machine learning algorithms in live backtesting and trading environments to improve prediction accuracy and maximize profit, using multiple strategies and more sophisticated algorithms such as self-attention RNN and LSTM.
Python & Metatrader Back Testing Systems | Developing & Test Trading ML Strategies
Python & Metatrader Back Testing Systems | Developing & Test Trading ML Strategies
  • 2021.06.24
  • www.youtube.com
Dr. Khushi supervised this master project in which they developed Python and MetaTrader based backtesting system, trading strategies and wrapped around machi...
 

How to create Algorithmic Trading Strategies with Python - Step by Step Process



How to create Algorithmic Trading Strategies with Python - Step by Step Process

The video provides a step-by-step guide on how to create algorithmic trading strategies using Python. The first step involves defining the rules for the system, eliminating emotions from trading, and conducting backtesting to optimize profitability. The presenter then demonstrates how to create a trading strategy using a hypothesis and technical indicators such as moving average crossovers. The strategy is then coded, and backtesting is conducted repeatedly to ensure optimization. The second section focuses on coding the algorithmic framework and creating a signal function that determines whether to buy or sell based on a comparison of simple moving averages. The third section discusses how to process live market data using functions, while the fourth describes how to deploy the strategy on WPS. The presenter concludes by advising beginners to keep their trading strategies simple and clear.

  • 00:00:00 In this section of the video, the presenter explains the process of creating algorithmic trading strategies with Python. Firstly, they define algorithmic trading as a system with explicitly defined rules and no exceptions. The advantages of this are that we can code trading strategies based on quantifiable data and emotions are taken out of the equation. They also mention that backtesting is easily done to optimize and test the system's profitability. Next, the presenter shows how to create a trading strategy by using a hypothesis and technical indicators, particularly moving average crossovers. With the information gathered, set of rules are created, and then the strategy undergoes backtesting. This process can be repeated until the strategy is deemed optimal.

  • 00:05:00 In this section, the speaker discusses the step-by-step process of creating algorithmic trading strategies with Python. They explain how backtesting allows traders to understand how their profit and loss is developing, and if successful, traders may move on to a forward test with a live trading bot on a demo account. The speaker also recommends using Python for trading as it is an easy language to learn and has many libraries for backtesting and algorithmic trading, such as pandas and plotly. Finally, the speaker walks through the process of creating a simple moving average crossover strategy on the German stock index, using a fast moving average of 10 and a slow moving average of 100. They emphasize the importance of coding the algorithmic framework, which can be found on their GitHub page.

  • 00:10:00 In this section, the presenter demonstrates how to use Python to create an algorithmic trading strategy using the moving average crossover strategy previously discussed. They provide two files: a backtested file and a live trading bot file. The backtested file includes data analysis of how the strategy performed for the year 2032. The live trading bot file requires the creation of a file with login credentials and allows users to trade using moving average crossovers. The presenter then shows their Python integrated development environment and explains the code, which uses libraries such as pandas, blockly, and datetime to retrieve historical data, calculate simple moving averages, and apply trading logic. Finally, the presenter creates a signal function that determines whether to buy or sell based on the comparison of the simple moving averages.

  • 00:15:00 In this section, the speaker explains the process of calculating the signal column that would indicate when to buy or sell a particular security. The signal column is derived by applying the "get signal" function to the data frame bars, which then checks row by row if the conditions for buying or selling are met. Additionally, the previous price change and signal change columns are also calculated to determine the hypothetical profits, taking into account the trade volume and the commission paid to the broker. The speaker then shows a plot using the gross and net profits over a six-month period, demonstrating that the strategy produced a net profit of €2,380, with some drawdown periods. Finally, the speaker mentions sharing sample code of the backtesting strategy in case the viewer wants to test it themselves for a longer history.

  • 00:20:00 In this section, the presenter explains how to process live market data using functions to create a trading strategy in Python. They suggest importing MetaTrader5, pandas, time, datetime, and account principles with the default parameters of their strategy. The presenter created functions for trading to close positions and check the trading hours of London and New York sessions. They also created a function to send a market order using a trading signal in the loop, and if the fast SMA is above the slow SMA, they suggest closing the sell positions. The presenter demonstrates how to use these functions and check the number of open positions with the MT5 Positions Total function to provide an overview of the account when logging into the trading account.

  • 00:25:00 In this section, the speaker explains the final step of the process which is deploying the strategy on WPS (Web Processing Service). He suggests using a DP (Cloud Desktop Provider) called Countable, to which he provides basic configurations. He also notes that MT5 only works on Windows and recommends selecting a UK hosted data center if the broker is located in London. The speaker then proceeds to give tips and recommendations to beginners, advising them to keep their strategies simple and clear, in order to later add on more over time. He concludes by thanking the viewer and encouraging them to ask questions in the comments.
How to create Algorithmic Trading Strategies with Python - Step by Step Process
How to create Algorithmic Trading Strategies with Python - Step by Step Process
  • 2022.08.28
  • www.youtube.com
In this video, I will explain how to create an Algorithmic Trading Robot Step by Step.00:00 - Presentation09:55 - Github Repo11:21 - Backtest19:55 - Live Tra...
 

Backtesting the 3-candle-setup with Python



Backtesting the 3-candle-setup with Python

The video demonstrates how to use Python to backtest the profitability of a three-candle setup. The presenter obtains weekly OHLC data for the EUR/USD currency pair from Metatrader5 and converts it to a Pandas dataframe, visualizing it using Plotly Express. They identify bullish and bearish candles using a specified candle type function and define the three-bullish-candle setup condition. By calculating the fourth candle's probability of going up or down for each occurrence of the setup, they backtest the profitability of buying these setups. The presenter concludes that going long on each bullish setup would have generated some income but emphasizes the importance of being patient since the profit comes in a quick period.

  • 00:00:00 In this section, the speaker discusses how to use Python to backtest the three-candle-setup. To do so, they first connect to the Metatrader5 platform and request OHLC data for the EUR/USD currency pair on a weekly timeframe from January 1st, 2019 to November, 2021. The data is then converted to a Pandas dataframe and visualized using Plotly Express. The speaker then shows how to label the candles in the dataframe as bullish or bearish using a specified candle type function. They use this to meet the condition for a three-bullish-candle setup by shifting the candle type column forward by one, two, and three candles, creating a condition where all three candles are bullish. They then calculate the probability of the fourth candle going up or down for each occurrence of this setup and backtest the profitability of buying these setups.

  • 00:05:00 this section of the video, the presenter discusses how to backtest a three-candle setup using Python. The setup involves identifying candles where the first, second, and third candle are all bullish. The presenter creates a dataframe with the previous close and compares the result with the previous candle to calculate the number of points gained or lost. They then proceed to analyze the data statistically to determine whether it would be a good idea to buy or sell. By iterating through each individual setup and adding the three candle setups on a plot, they show that buying at the close of each setup and selling immediately after the closure of the next candle would be profitable in some situations. The presenter calculates the number of times the setup occurs and how much would be gained or lost on average per setup. They conclude that going long on each bullish setup would have generated some income.

  • 00:10:00 In this section, the video introduces an example of backtesting the 3-candle-setup with Python. After resetting the axis, it shows the period of time with losing and profiting trades in 2019 with the profit curve of cumulative points. The profit comes in a quick period, requiring patience until this period arrives. The video also demonstrates how to analyze XA USD on the daily chart and view its performance by requesting historical data and plotting the data frame. The profit curve is used to see the ups and downs in profits and losses. Lastly, the video concludes that this method of testing can be used on any number of markets and timeframes and implies that users can write their own algorithmic strategies.
Backtesting the 3-candle-setup with Python
Backtesting the 3-candle-setup with Python
  • 2021.11.12
  • www.youtube.com
In this video, we will backtest 3 candles in-a-row setup for algorithmic trading.Chapters00:00 Intro00:55 Requesting Data & Visualization03:33 Finding the 3-...
 

Code Real-Time Candlestick Charts in Python



Code Real-Time Candlestick Charts in Python

In this video, the author creates a web application in Python using Dash, pandas, and plotly to generate a real-time candlestick data chart for FOREX trading. The application uses the MetaTrader 5 library to collect data and allows users to change the symbol, time frame, and number of candles to display. The video goes through the process of creating the layout and callbacks for the application, including requesting historical bars from MetaTrader 5 and creating a figure object with go.candlestick. The resulting application updates every 20 milliseconds and has a 200 millisecond update interval. Viewers are invited to visit the GitHub page to download the application.

  • 00:00:00 In this section, the YouTuber answers a viewer's question about creating a live forex data chart with real-time streaming candlestick data. The video explains how the YouTuber codes a web application in Python using Dash, pandas, and plotly for data analysis and visualization while using the MetaTrader5 library to collect data from MetaTrader 5. They also explain the process of getting a list of symbols and translating the time frames using a dictionary. The resulting output of the application is a chart where users can change the symbol, time frame, and number of candles to display data in real-time with a 200 millisecond update interval.

  • 00:05:00 In this section of the video, the speaker explains the creation of the layout for the real-time candlestick chart application. The drop-down components for symbol and time frame are imported from MT5 functions, and the values are set to default. The number of bars input is created using the DBC input field, which has a default value of 20. The app layout consists of an HTML div, which includes the symbol drop-down, time frame drop-down, and number of bars input. A small separator is added, followed by the DCC interval component that creates a new callback every 200 milliseconds to update the real-time chart. The page content includes a callback that updates the chart every 20 milliseconds, taking in the state of the symbol drop-down, time frame drop-down, and number of bars input. The callback requests historical bars from MetaTrader 5 and creates a figure object with go.candlestick. Finally, the speaker thanks the viewers for their attention and invites them to visit the GitHub page to download the application.
Code Real-Time Candlestick Charts in Python
Code Real-Time Candlestick Charts in Python
  • 2021.11.25
  • www.youtube.com
In this video, we will code a Real-Time Candlestick Web Application in Python. We will connect to MetaTrader5 to get real-time data and use Plotly-Dash to cr...
Reason: