Something Interesting in Financial Video - page 32

 

Forum on trading, automated trading systems and testing trading strategies

Python in algorithmic trading

MetaQuotes, 2023.04.18 11:40

1. MetaTrader 5 Python Library and Connecting Python with MetaTrader 5



1. MetaTrader 5 Python Library and Connecting Python with MetaTrader

The video showcases step-by-step instructions for installing the MetaTrader 5 Python library and setting up a connection between MetaTrader 5 and Python using account details. The presenter explains the process in detail, including how to search and install the Metatrader5 package, how to import the library, and how to establish a successful connection with a trading account. Overall, the video serves as a useful guide for those looking to integrate MetaTrader 5 with Python.


 

Forum on trading, automated trading systems and testing trading strategies

Python in algorithmic trading

MetaQuotes, 2023.04.18 11:40

2 Placing Buy Limit and Sell Limit Orders with Python



2 Placing Buy Limit and Sell Limit Orders with Python

This video demonstrates the process of placing buy and sell limit orders using Python's `empty_file.order_send()` function and key-value pairs. The user can provide the currency symbol, volume, and order type as inputs to the function to place a buy limit order. The video also shows how to create custom functions for placing limit orders and capture output using variables. The same process applies to sell limit orders, with the type and price specified differently.


 

Forum on trading, automated trading systems and testing trading strategies

Python in algorithmic trading

MetaQuotes, 2023.04.18 11:47

Code Your Own Trading Bot with ChatGPT and Python



Code Your Own Trading Bot with ChatGPT and Python #chatgpt #trading

In this video, I'll show you the easiest and fastest way to build a ChatGPT trading bot for MetaTrader 5 using module for Python and ChatGPT

For this example, we're using only 1 indicator in the video, but you can create your own custom logic using multiple indicators or even implement machine learning!

ChatGPT prompt that is used: " Write me a MetaTrader 5 Module for Python code that connects using acc, password, and server to MetaTrader 5 terminal, implement a function to calculate RSI manually without using TALIB, it should calculate it based on the last 100 candles for the symbol EURUSD in the 1-minute timeframe, and implement buy and sell orders based on the signals of the RSI indicator. On top of the code, declare variables so you're not repeatedly declaring them in functions or the rest of the code, like account, password, server, symbol, timeframe, number of candles, stop loss pips, take profit pips, and so on. To calculate RSI, we first need to calculate the exponential weighted average gain and loss during the period then we use the same formula to calculate Exponential Moving Average. the Relative Strength is the ratio between the exponential avg gain divided by the exponential avg loss. the RSI is calculated based on the Relative Strength using the following formula. calculating the range of each candle then calculating the average value of the ranges RSI is the average value of the ranges. "


 

Forum on trading, automated trading systems and testing trading strategies

Python in algorithmic trading

MetaQuotes, 2023.04.18 12:35

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.

 

Hello sir, thank you so much for the amazing content you have shared with us. Yesterday I was watching a video with name "How to really use overbought and oversold indicators". I don't see that video today. could you please help me find that video.


Thank You

 
Lalit Kumar #:

Hello sir, thank you so much for the amazing content you have shared with us. Yesterday I was watching a video with name "How to really use overbought and oversold indicators". I don't see that video today. could you please help me find that video.


Thank You

How To REALLY Use Overbought And Oversold Indicators


This is the small educational video about how to use standard indicators for overbought/oversold levels trading.

--------------

On Methods to Detect Overbought/Oversold Zones - the article 

over bougt/over sold levels - educational forum thread

Forum on trading, automated trading systems and testing trading strategies

over bougt/over sold levels

Sergey Golubev, 2017.08.25 11:03

The forum threads/posts about it

  • What does it mean a currency to be Overbought and Oversold? - the thread 
  • Overbought vs. Oversold - the post with mini-article
  • RSI based overbought / oversold levels - small thread with indicator (MT4)
  • Video Lessons - Ichimoku With Oversold and Overbought Levels - the post with video
  • Video Lessons - Overbought and Oversold levels - the post with video
  • Stochastic - small thread with trading system based on standard indicators in Metatrader
  • Something Interesting to Read - Theory Of Stochastic Processes - the thread with the books

Forum on trading, automated trading systems and testing trading strategies

over bougt/over sold levels

Sergey Golubev, 2017.08.25 10:37

There are many indicators providing overbought/oversold levels, and you can select them in CodeBase.

============

You can look at the following indicators for example:

============

Example to use those levels: +135 pips

============




 

Forum on trading, automated trading systems and testing trading strategies

Quantitative trading

MetaQuotes, 2023.05.12 12:25

Interview With A Legend In Algorithmic Trading Dr. Ernie Chan



Interview With A Legend In Algorithmic Trading Dr. Ernie Chan

Dr. Ernie Chan, an expert in algorithmic trading, emphasizes the importance of simplicity, risk management, and human judgment in successful trading strategies. He highlights the value of personal experience and expertise in crafting effective strategies and advises traders to remain humble, stay focused, and guard against overconfidence and data snooping bias. Furthermore, Dr. Chan recommends balancing mean reversion and momentum strategies in a portfolio and developing multiple algorithmic systems that are not correlated with each other to ensure a stable return for clients. Finally, he stresses the importance of statistical robustness tests and historical data analysis in determining a strategy's effectiveness and adapting it for new market phenomena.

Dr. Ernie Chan, a legend in algorithmic trading, shares how his portfolio of strategies has evolved by allocating to successful traders and focusing on machine learning-based risk management. He believes that there is no unique indicator that captures all aspects of market reality and that multiple indicators can be used to observe the same reality, which should be screened properly by the machine learning approach. He also talks about his project PredictNow.ai, which offers a probability of loss for every future period using machine learning. Dr. Chan emphasizes the importance of having passion in algorithmic trading and reminds traders to keep their strategies simple, practice on simulators, and check risk levels before investing real money.

  • 00:00:00 In this section, the interviewer introduces Dr. Ernie Chan, a legend in algorithmic trading who has been involved in the financial markets and trading for many years. Dr. Chan has a Ph.D. in physics and has worked for IBM, Morgan Stanley, and Credit Suisse in the development of automated trading systems. He is an institution in the space of machine learning and artificial intelligence and has written several books around algorithm and automated trading systems. The co-host for the interview, Norm, shares that Dr. Chan was the first person with significant knowledge to write about algorithmic trading over ten years ago and that his book set them on the path to developing a process for how to develop algorithmic systems. Dr. Chan shares that he had a theoretical physics background and was passionate about machine learning, which led him to research at IBM.

  • 00:05:00 In this section, Dr. Ernie Chan discusses how he transitioned from working in research at IBM to working in finance. He explains that his interest in finance was initially sparked by coworkers leaving IBM to work at Renaissance Technologies, a hedge fund that was not well known at the time. After moving to Manhattan to work in finance, Dr. Chan began working on machine learning strategies for trading but eventually gave up on this approach after finding it to be extremely difficult to find a sustainable edge. He then transitioned to retail trading and discovered that simple strategies often work best, a lesson he shared in his book. Dr. Chan also notes that there is a new understanding of how machine learning can be applied to risk management rather than alpha generation, a realization that is shared by many experts in the field.

  • 00:10:00 In this section, Dr. Ernie Chan discusses the importance of simplicity in algorithmic trading and how machine learning can help improve trading strategies by predicting when they are likely to lose money. He emphasizes that discretionary traders should not underestimate the human mind and the value of their own judgment, but should also work on disciplining their thinking and emotions to overcome fear and greed. Additionally, he notes that some discretionary traders could benefit from improving their strategies with a more logical and disciplined approach.

  • 00:15:00 In this section, Dr. Ernie Chan discusses how controlling fear is crucial for discretionary traders and how machine learning-based risk management systems can help even discretionary traders. He explains that if traders have a consistent style in their discretionary trading program and have a long enough track record, machine learning can learn from it to find out under what circumstances the strategy tends to suffer. This can be augmented by implementing a systematic risk management layer like determining leverage and capital allocation. He also suggests that traders with different strengths, such as a deep understanding in a particular industry, can use their expertise to find a profitable trading strategy.

  • 00:20:00 In this section of the interview, Dr. Ernie Chan discusses the importance for new traders to filter trading strategies through their own expertise and experience. Trading should not just be about following other people's ideas, but about adding your own edge and validating your ideas through personal experience. He also notes that some traders gravitate towards overly complex systems as an intellectual challenge, but this should not be the primary motivation for trading. Dr. Chan also shares that putting money on the line is essential for confronting the reality that the primary goal of trading is not intellectual excitement, but rather not losing money. It is important to put a significant but manageable amount of money on the line to focus the mind.

  • 00:25:00 In this section, Dr. Ernie Chan explains how one should remain humble in front of the market and focus on what really works. He advises traders to remain focused and observe the market phenomenons that not everyone has observed. While a lot of his traders come from academic backgrounds and have brilliant mathematical and computational skills, they find it difficult to create a strategy that generates real profit. This is mainly because they don't have their own personal wealth on the line. Dr. Chan emphasizes the importance of having your own money on the line to become a trader and how that distinguishes a trader from a researcher. In the following discussion, Norm and Dr. Chan discuss their trading processes and strategies.

  • 00:30:00 In this section, Dr. Ernie Chan emphasizes the importance of minimizing maximum loss to win in trades. He advises that manual traders should paper trade for some time before trading a live account and use simulated training environments to accelerate the learning process. He also mentions the concept of regime change and suggests that traders keep a check on their confidence and avoid over-leveraging their trades. Moreover, he noted that market environments can change, and traders need to experience a change of market conditions to be sure that their strategy is insensitive to that situation.

  • 00:35:00 In this section, Dr. Ernie Chan talks about the importance of not being able to see the future when developing or testing a trading system, called data snooping. While it may seem obvious that having tomorrow's Wall Street Journal today would result in becoming an instant billionaire, there are more subtle ways in which data snooping can occur, particularly with emotion and hindsight bias. Dr. Chan advises using different instruments for training data to avoid overfitting and testing a strategy on multiple assets. Additionally, he suggests monitoring performance for signs of decreasing returns and making necessary adjustments to prevent risk.

  • 00:40:00 In this section, Dr. Ernie Chan emphasizes the importance of fundamental knowledge about the market and strategy when determining if a system is working as expected or requires tweaks. He mentions the need to understand market structure changes and read academic research to make a judgment. For example, understanding the effect of retail traders buying call options due to Wall Street Bets can have both positive and negative impacts on different strategies. He also advises traders to adapt their strategy to new phenomena by tweaking their approach and gives insight into how to quantify drawdowns. Overall, he suggests that both quantifiable data and intuition are important when determining if a strategy has stopped working.

  • 00:45:00 In this section, Dr. Ernie Chan discusses the importance of historical data in algorithmic trading and how it can be beneficial for manual traders as well. He emphasizes the need to have trigger points for trading systems, which are based on historical testing. If a system approaches maximum drawdown or suffers stagnation, it is likely to be pooled and replaced with a more robust one that fits its place. Dr. Chan suggests that practicing on historical data can give traders statistically significant ideas about how their trading system will perform and what kind of consistency and profit they can expect, as well as prepare them for possible drawdowns. When a system is not performing as expected, it may be time to have a proper sit-down and look at the system's mechanics to address the issue. Dr. Chan also mentions that his portfolio has a mix of both mean-reverting and momentum-led trading strategies.

  • 00:50:00 In this section, Dr. Ernie Chan discusses the importance of balancing the mean reversion and momentum strategies in a portfolio, particularly in times of volatility. Mean reversion strategies can provide consistent returns but can quickly fall apart in a crisis, while momentum strategies can help keep portfolios intact during downturns. Dr. Chan recommends having a combination of both strategies to deliver consistent returns for clients in normal times and outside returns during crises. He also mentions developing a long-term swing trading strategy that combines elements of both strategies with short stop losses and high-profit factors.

  • 00:55:00 In this section, Dr. Ernie Chan discusses his approach to creating multiple algorithmic trading systems that aren't correlated with each other. He describes his process of layering systems and forcing the machine not to make one similar to the ones that have gone before it. He explains that over time, their algorithms have shifted from automating systems to data mining where they are statistically letting the machine do it all. He further explains the importance of finding the most robust system rather than the luckiest system when experimenting with new models and the need for statistical robustness tests.

  • 01:00:00 In this section, Dr. Ernie Chan explains how his portfolio of strategies has evolved in two ways; allocating to traders who already have a successful track record and engaging in their own in-house research, focusing on machine learning-based risk management. He also highlights that the systems that work for him are conceptually simple and that there is no unique indicator or suite of indicators that capture all aspects of market reality. Instead, he believes that multiple different indicators can be used to observe the same reality, and that the machine learning approach screens them properly to decide which indicators are the most successful.

  • 01:05:00 In this section, Dr. Ernie Chan speaks about PredictNow.ai, a project he has been working on for over a year, which provides a risk management service for traders based on machine learning. Rather than relying on market signals, the service learns from each trader's return and offers a probability of loss for every future period, allowing traders to decide how much leverage to use for a trade. Dr. Chan can be contacted via his Twitter account or blog, and his parting advice is to keep trading strategies simple, practice on simulators, and check risk levels before investing real money.

  • 01:10:00 In this section, Dr. Ernie Chan emphasizes the importance of having passion in algorithmic trading as it is a tough business that requires perseverance and experimentation. He believes that having passion as an underpinning factor is what keeps traders going forward despite failures or unfavorable results. He also expresses his gratitude towards the interviewers and concludes the interview with a reminder to like, subscribe, and comment on their channel.

 

Forum on trading, automated trading systems and testing trading strategies

Machine Learning and Neural Networks

MetaQuotes, 2023.05.11 19:58

Should We Be Fearful of Artificial Intelligence? w/ Emad Mostaque, Alexandr Wang, and Andrew Ng | 39



Should We Be Fearful of Artificial Intelligence? w/ Emad Mostaque, Alexandr Wang, and Andrew Ng | 39

The guests in this YouTube video discuss various aspects of artificial intelligence (AI), including its potential dangers, disruption in various industries, and the importance of re-skilling workers to stay relevant. The panelists also debate the usability of AI tools, the implementation of AI in healthcare, standardization in information distribution systems, the potential for wealth creation in AI, and the use of language models in healthcare and education. Additionally, they stressed the need for responsible deployment of AI models, transparency, and ethical considerations in governance. Lastly, the panelists briefly answer some audience questions on topics such as privacy in AI for healthcare and education.

  • 00:00:00 The guests discuss the potential dangers of AI and the need for transparency and caution when it comes to this technology. They also touch on the disruption that AI is causing in various industries and the importance of re-skilling workers to stay relevant in the face of this disruption. The guests offer potential solutions, such as online education and partnering with governments, to help people adapt to the changes brought about by AI. Ultimately, they believe that AI has the potential to create wealth faster than anything we've ever seen and uplift everyone, but must be treated with care and responsibility.

  • 00:05:00 The experts discuss the usability of AI tools in comparison to Google's user-friendly interface. They hope that AI tools could evolve to become easier to use without requiring much education. The generative AI is trained on large corpuses of an entire media set and is focused on natural language understanding. However, they agree that the policy and adoption of AI are relatively uncertain, and education courses and communication with policymakers could make it more accessible. The panel also talks about the challenges of defining concepts in AI programming, and the need for well-defined unique structural names alongside the growing use of prompts.

  • 00:10:00 A physician from Chicago asks the panelists on how AI can be used most efficiently in healthcare in terms of point of care and patient evaluation. The panelists suggest finding concrete use cases and executing them to gain an advantage in the market, as getting to the market first is key. They also recommend building a data set through tools like euroscape.com and labeling and annotating the data to train a new model on top of it. They suggest partnering with other companies or bringing in a team to develop and implement AI, potentially starting small and expanding gradually.

  • 00:15:00 The speakers discuss whether there is any commercial activity that AI will never be able to disrupt. While some physical tasks and industries may be further from being disrupted by AI than others, the speakers ultimately agree that there is no commercial activity that AI will never be able to disrupt. However, they do discuss the challenge of interpreting AI decisions, and the need for centralized repositories of trust and standards to curate information and combat the spread of false or misleading information on social networks.

  • 00:20:00 The speakers discuss the need for standardization in information distribution systems to adapt to the increasing adoption of artificial intelligence (AI). They also touch upon the importance of ethical considerations and the implications of AI, as it is happening currently and will continue to shape the future. The conversation shifts towards the practical applications of AI in disaster recovery, where it can be used for fast response times and coordination of humanitarian efforts. The panel also discusses the role of a Chief AI Officer, who should have a technical understanding of the technology and a business-oriented mindset to identify valuable use cases for AI.

  • 00:25:00 The speakers discuss the implementation and passion necessary to keep up with AI technology. They suggest creating an internal repository for companies to keep up with the latest trends in AI and recommend cataloging all existing data that can be uploaded into AI systems. They also discuss the potential for wealth creation in the AI industry and recommend investing in upskilling oneself or a company in this area. Although some may feel it's too late to jump in, the speakers suggest that it's actually still early days for AI and that significant growth is expected in the near future.

  • 00:30:00 Peter discusses the importance of monitoring glucose levels and recommends Levels, a company that provides continuous monitoring of glucose levels to ensure that individuals are aware of how different foods affect them based on their physiology and genetics. The conversation then shifts to how technology can contribute to world peace, with an emphasis on how AI can function as a universal translator and provide context and understanding between different points of view. The panelists also touch on the topic of open AI and its dismissal of its Ethics Committee, with one member expressing admiration for the work done by open AI but also acknowledging concerns about the decision.

  • 00:35:00 The speakers discuss the responsibility that comes with deploying large AI models and the potential trade-off of the benefits they bring versus the risks they pose. They touch on OpenAI's responsible deployment of the technology and acknowledge the efforts of ethical AI teams who are trying to mitigate the negative aspects of AI use. The conversation also covers the need for transparency and responsible governance when it comes to potentially dangerous technology. Finally, the speakers address the use of AI in investment decision-making, acknowledging the complexity of the process and the limitations of current technology.

  • 00:40:00 The group discusses the use of language models in healthcare, specifically for building chatbots that support nursing or triaging staff. They mention using stable chat models like GPT-Neo and TF-Plan T5, but caution that as healthcare data is highly sensitive, creating an open-source model that can be controlled and owned is critical. The group also discusses the use of language models in education, specifically the controversy around using tools like Chad-GPT for writing essays or book reviews. They debate the merits of transparency and how to train students to use these tools effectively without limiting their growth. Lastly, the group grapples with the question of what defines cheating in an educational context.

  • 00:45:00 The panelists briefly answer some questions from the audience in a speed round. The topics include content creation in music and arts, privacy in AI for healthcare, and whether a 15-year-old should continue taking Python and go to college. The panelists touch on the importance of data privacy and the need for auditable and interpretable AI in healthcare. They also mention that the ethics of AI and its potential misuse by countries like China will be discussed in the next session.

 

Forum on trading, automated trading systems and testing trading strategies

Python in algorithmic trading

MetaQuotes, 2023.05.16 17:36

Algorithmic Trading Python 2023 - FULL TUTORIAL Beginner


Algorithmic Trading Python 2023 - FULL TUTORIAL Beginner

In this video tutorial, the author delves into the process of installing and utilizing a Python program for algorithmic trading. They provide step-by-step instructions on creating a basic Python 3 file specifically designed for housing code related to algorithmic trading strategies. Moreover, they demonstrate how to execute the code and print the resulting outputs for analysis. The tutorial primarily focuses on harnessing the power of the Python programming language for algorithmic trading purposes. It covers a range of essential functions and libraries applicable to algorithmic trading, including the yfinance library. The tutorial highlights the significance of using these functions and libraries while also exploring data download and processing techniques using spreadsheets.

Additionally, the video tutorial showcases the process of writing and reading CSV files using Python. It explains the necessary steps for creating a CSV file and demonstrates how to read and manipulate the file within a Python environment. Continuing with the theme of Python-based stock trading, the tutorial elucidates the creation of a stock index and demonstrates how the Python function "convert" can be used to modify the index format. Furthermore, it explains how the Python function "start.columns" facilitates changes to the column list specifically for stocks.

The next video tutorial also revolves around using Python for stock trading. It commences by illustrating the download and parsing of stock data, followed by employing the "describe" function to analyze the acquired data effectively. Lastly, it demonstrates the utilization of the "dot lock" function to monitor and track stock prices. Moving on, the subsequent video tutorial provides a comprehensive explanation of using Python to create algorithms for stock trading. It begins by visualizing different starting points for three distinct stocks, subsequently illustrating the normalization of values to represent them within a uniform 100-point range. The tutorial then guides viewers on plotting the normalized closing prices of a stock and utilizing the "dot" (mole) function to multiply the values by 100, enhancing readability.

Similarly, another video tutorial focuses on utilizing Python to create stock trading algorithms. The tutorial outlines the process of creating a new column within a dataset to store information regarding closed stocks. It further explains the utilization of the "shift" function to relocate data to the bottom of the column. Additionally, it showcases the calculation of percentage changes in stock prices from the previous day. Shifting gears, another tutorial introduces learners to utilizing Python for statistical calculations related to algorithmic trading. It provides guidance on employing functions such as "shift," "subtract," and "divide" to compute lag and diff-related data.

Next, the video delves into calculating percentage changes for financial assets using Python. It demonstrates modifying the "change" function to improve readability by renaming it as "pst." Furthermore, it sets the "periods" variable to one and multiplies the percentage change by 100 to represent it in point value format. The video also covers calculating the standard change for an asset, subtracting it from the percentage change to eliminate the impact of the first day. The dataframe for a specific asset is renamed as "change," and the "change" column is created. The tutorial concludes with running a check on the "change" column using "aafl" and saving the dataframe.

Moreover, the tutorial author explains how to calculate mean, standard deviation, percentage change, and returns for a given dataset. They also demonstrate plotting a histogram and creating a hit system graph.

Continuing with statistical calculations, another video tutorial explains calculating the mean, variance, and standard deviation of a stock's returns. Additionally, it provides guidance on determining the annual mean return and the annual variance return.

Expanding further, the tutorial showcases calculating the annual standard deviation of a stock's returns using the "std" function in Python. This approach efficiently analyzes large datasets by taking data from a ticker symbol instead of individual data points. The tutorial also demonstrates creating columns to track the mean and standard deviation of a stock's return, as well as the mean and standard deviation of a stock's percentage change. It further explains calculating the mean and standard deviation of a stock's return using the "summary" function.

The author also covers the creation of scatter plots and annotating them to illustrate the return and risk associated with different stocks. This visualization helps in understanding the relationship between returns and risks in the context of stock trading. Moving on, the video tutorial delves into using Python to create algorithms for trading stocks. It explores the usage of for loops and functions such as covariance and correlation. Additionally, it showcases the graphical representation of the algorithm's results, enabling traders to visualize and analyze the performance of their trading strategies effectively.

Furthermore, the tutorial explains how to leverage the seaborn library to create a heatmap depicting stock correlations. It provides a step-by-step guide along with a code download for the entire project, facilitating the implementation of stock correlation analysis using Python. Shifting focus, the presenter in a video tutorial educates viewers on calculating the risk and reward potential of a portfolio of stocks using Python. They discuss the limitations of simple returns and introduce the concept of log returns, demonstrating their practical application in assessing risk and reward. This analysis helps traders make informed decisions regarding their portfolio composition and risk management.

Another tutorial elucidates the process of calculating a simple moving average using the "rolling" function in Python. By applying this technique, traders can smoothen the fluctuations in stock prices and identify trends more effectively. In addition, a tutorial demonstrates the calculation of the mean, median, and moving average of a dataset, emphasizing their significance in analyzing and understanding data patterns.

Moreover, a video tutorial showcases the calculation of various moving averages, including the 50-day moving average, 200-day moving average, and EMA (earnings-to-price) of a stock. These moving averages are then plotted on a graph, aiding traders in identifying key trends and potential trading signals. Continuing with data manipulation techniques, a video tutorial explains the utilization of the re-index function in pandas to replace missing values within a dataframe. It also covers the application of forward and backward fill functions to manage data when encountering holidays and weekends.

The video tutorial further demonstrates the calculation of returns for a stock over time, encompassing buy and hold returns, cumulative returns, and maximum returns. Additionally, it explores the computation of cumulative maximum returns and visualizes the data through graph plotting. Furthermore, the tutorial explains how to calculate drawdowns for a stock, as well as the maximum cumulative return and maximum cumulative drawdown. Understanding drawdowns helps traders assess the risk associated with investments and identify potential loss scenarios. In a similar vein, another video tutorial discusses calculating drawdown and maximum drawdown for a stock. Additionally, it provides an overview of calculating percent drawdown, a crucial metric in risk management.

A Python 2023 tutorial on YouTube introduces viewers to creating a moving average crossover strategy for trading. This strategy involves utilizing two moving averages, a 50-day moving average, and a 100-day moving average, to determine the stock's trend and generate trading signals accordingly. Moreover, a video tutorial explains how to write Python code for trading stocks. It demonstrates the process of determining whether to buy or sell a stock based on its current price and past price data. It also covers using a library to track a stock's position over time, allowing traders to monitor and manage their portfolio effectively.

The tutorial video enlightens viewers on backtesting an algorithmic trading strategy using returns and standard deviation. It showcases a strategy that outperforms a 50-day moving average in terms of returns but comes with higher standard deviation, highlighting the trade-off between risk and reward. Additionally, the video tutorial guides users through creating an investment strategy and comparing it to other strategies. It emphasizes that the strategy with the best returns is the one with a long bias, indicating a preference for bullish positions.

Furthermore, the author introduces a function to create a test strategy for algorithmic trading. This function takes parameters such as stock name, start and end dates, and returns key performance metrics such as daily return, cumulative return, and SMA (Simple Moving Average). By utilizing this function, traders can assess the effectiveness of their trading strategies and make data-driven decisions. The tutorial then proceeds to demonstrate how to build an algorithmic trading Python script. The script incorporates a simple stop-loss and take-profit strategy, aiming to achieve better overall performance compared to a traditional buy-and-hold investment approach. This script serves as a foundation for developing more sophisticated trading algorithms.

The presenter also showcases the process of backtesting a trading strategy written in Python. The strategy, created by the presenter, is tested on historical stock market data from 2017, enabling traders to evaluate its performance and viability. Moreover, the tutorial explains how to code a Python2023 algorithm for trading stocks and cryptocurrencies. It covers the utilization of APIs to access data from various stock and cryptocurrency exchanges, enabling traders to analyze real-time market data and implement trading strategies accordingly. The video tutorial further explores using Python to trade stocks and cryptocurrencies. It encompasses data entry, analysis, storage, manipulation, and the execution of trade strategies using API services. By leveraging these techniques, traders can automate their trading processes and efficiently manage their portfolios.

Additionally, the tutorial provides comprehensive guidance on using Python to trade stocks and other financial assets. It covers fundamental concepts such as price analysis and trading, as well as advanced topics like backtesting and utilizing APIs for data integration. This tutorial equips traders with the necessary knowledge and tools to engage in algorithmic trading effectively.

In conclusion, these tutorials and videos offer a wealth of information on using Python for algorithmic trading. They cover a wide range of topics, including data processing, statistical analysis, visualization, strategy development, backtesting, and real-time trading. By following these tutorials, traders can enhance their understanding of algorithmic trading principles and leverage Python's capabilities to make informed trading decisions.

  • 00:00:00 In this video, the author discusses how to install and use an algorithmic trading Python program. Next, they explain how to create a basic Python 3 file to hold code for an algorithmic trading strategy. Finally, they show how to run the code by printing the results.

  • 00:05:00 This tutorial explains how to use the Python programming language to perform algorithmic trading. The tutorial covers various functions and libraries that can be used in algorithmic trading, such as the y finance library. The tutorial also shows how to download and process data in a spreadsheet.

  • 00:10:00 This YouTube video demonstrates how to write a CSV file and how to read it in Python.

  • 00:15:00 This tutorial explains how to use Python to trade stocks. The video first explains how to create a stock index, and then shows how to use the Python function convert to change the index format. Finally, it explains how to use the Python function start.columns to change the column list for stocks.

  • 00:20:00 This video tutorial discusses how to use Python to trade stocks. The first part of the tutorial covers how to download and parse stock data. Next, the tutorial covers how to use the describe function to analyze the data. Finally, the tutorial covers how to use the dot lock function to keep track of stock prices.

  • 00:25:00 This video tutorial explains how to use the Python programming language to create an algorithm to trade stocks. The tutorial starts by displaying the different starting points for three different stocks, and then demonstrates how to normalize the values so that they are all represented in 100-point ranges. Next, the tutorial shows how to plot the norm of a stock's closing price, and how to use the
    dot (mole) function to multiply the values by 100 to make them easier to read.

  • 00:30:00 This video tutorial demonstrates how to use the Python programming language to create algorithms to trade stocks. The first step is to create a new column of data to store the information about the stocks that have been closed. Next, the video explains how to use the shift function to move the data to the bottom of the column. Finally, the tutorial shows how to calculate the percentage change in stock prices from the previous day.

  • 00:35:00 In this tutorial, you will learn how to use the Python programming language to calculate various statistical data related to algorithmic trading. You will learn how to use the shift, subtracted, and divided by functions to calculate data related to lag and diff.

  • 00:40:00 The video covers how to calculate the percentage change for a financial asset using Python. The change function is changed to pst to make it easier to read, and then the periods variable is set to equal one. The percentage change is then multiplied by hundred to convert to a point value. The standard change for the asset is then calculated and subtracted from the percentage change to remove the first day's effect. The dataframe apple is renamed to change and the column change is created. Aafl is run to check the column changes and the dataframe is saved.

  • 00:45:00 In this tutorial, the author demonstrates how to calculate the mean and standard deviation of a particular data set, as well as the percentage change and returns on the monthly change. He also demonstrates how to plot a histogram and hit system graph.

  • 00:50:00 This video explains how to calculate the mean, variance, and standard deviation of a stock's returns. The video also explains how to calculate the annual mean return and how to calculate the annual var return.

  • 00:55:00 This video tutorial explains how to calculate the annual standard deviation of a given stock's return using the std function. The std function takes in data from a ticker symbol, rather than individual data points, which makes it more efficient for analyzing large data sets. The tutorial also shows how to create a column to track the mean and standard deviation of a stock's return, as well as a column to track the mean and standard deviation of a stock's percentage change. Finally, it explains how to calculate the mean and standard deviation of a stock's return using the summary function.

  • 01:00:00 The author explains how to create a scatter plot and annotate it to show the return and risk associated with various stocks.

  • 01:05:00 This video tutorial explains how to use the Python programming language to create algorithms for trading stocks. The tutorial covers the use of for loops and the covariance and correlation functions, as well as a graphical representation of the results.

  • 01:10:00 This tutorial explains how to use the seaborn library to create a heat map of stock correlations. The tutorial also includes a code download for the entire project.

  • 01:15:00 In this video, the presenter teaches how to calculate the risk and reward potential of a portfolio of stocks using Python. He discusses the limitations of simple returns and log returns and demonstrates how they work in practice.

  • 01:20:00 This tutorial explains how to calculate a simple moving average using the rolling function in Python.

  • 01:25:00 This tutorial demonstrates how to calculate the mean and median of a set of values, as well as the moving average.

  • 01:30:00 This video demonstrates how to calculate the 50-day moving average, 200-day moving average, and ema (or "earnings-to-price") of a stock. The video also demonstrates how to plot these averages on a graph.

  • 01:35:00 In this video, dot day explains how to use the re-index function in pandas to replace missing values in a dataframe. The video also covers how to use the forward and backward fill functions to manage data when there are holidays and Saturdays and Sundays included.

  • 01:40:00 This video explains how to calculate the returns for a stock over time, including buy and hold returns, cumulative returns, and maximum returns. It also discusses how to calculate cumulative maximum returns and how to plot a graph of the data.

  • 01:45:00 This video explains how to calculate the drawdowns for a stock, and how to calculate the maximum cumulative return and maximum cumulative maximum for a stock.

  • 01:50:00 The video discusses how to calculate the drawdown and maximum drawdown for a stock, and also provides an overview of how to calculate the percent drawdown.

  • 01:55:00 In this YouTube video, a Python 2023 tutorial explains how to create a moving average crossover strategy. The strategy involves using two moving averages, a 50 day and a 100 day, to determine the stock's trend.

  • 02:00:00 This video tutorial explains how to use Python to write code to trade stocks. The video demonstrates how to write code to determine whether a stock should be bought or sold, based on its current price and past price. The video also explains how to use a library to track a stock's position over time.

  • 02:05:00 The video explains how to backtest an algorithm trading strategy using returns and standard deviation. The strategy achieves a higher return than a 50-day moving average, but has a high standard deviation.

  • 02:10:00 This video explains how to create a strategy for a given investment, and how to compare it to other strategies. The strategy with the best returns is the strategy with the long bias.

  • 02:15:00 The author introduces a function to create a test strategy for algorithmic trading. The function takes in a stock name, start and end date, and returns the daily return, the cumulative return, and the sma.

  • 02:20:00 This tutorial shows how to create a Python algorithm to trade stocks, and how to use it to make predictions about future stock prices. The tutorial includes a demonstration of how to calculate the return on an investment in a stock, as well as the standard deviation of that return.

  • 02:25:00 The sma backtester class is used to create a strategy that calculates returns and standard deviation. The class also includes a function to get data.

  • 02:30:00 The video demonstrates how to use the getdata function to download stock data, how to create a test result function, and how to calculate the performance and outperformance of a buy and hold strategy using the data.

  • 02:35:00 The author demonstrates how to calculate the performance and out performance of an algorithmic trading strategy. The author also demonstrates how to create a function to plot the results.

  • 02:40:00 In this tutorial, the author teaches how to build an algorithmic trading Python script. The script uses a simple stop-loss and take-profit strategy to achieve an overall performance advantage over a buy-and-hold investment.

  • 02:45:00 This video shows how to back test a trading strategy written in Python. The strategy was written by the presenter and was tested on the stock market in 2017.

  • 02:50:00 This tutorial explains how to code a Python2023 algorithm for trading stocks and cryptocurrencies. The tutorial also covers how to use an API to access data from various stock and cryptocurrency exchanges.

  • 02:55:00 This video tutorial explains how to use Python to trade stocks and cryptocurrencies. The video covers how to enter and analyze data, how to store and manipulate data, and how to send a trade strategy using API services.

  • 03:00:00 This tutorial explains how to use Python to trade stocks and other financial assets. The course covers basic concepts such as price analysis and trading, as well as more advanced topics such as backtesting and using APIs.

 

Forum on trading, automated trading systems and testing trading strategies

Programming tutorials

MetaQuotes, 2023.05.24 16:53

Code complete EA for MetaTrader 5 in 20 Minutes!



Code complete EA for MetaTrader 5 in 20 Minutes!

Today, we are excited to start recording our first EA (Expert Advisor) for the MetaTrader trading platform. This EA is designed to be a trading system for MetaTrader, and in our video, we will also perform a quick backtest to evaluate its performance.

To begin, we launch the MetaTrader platform and access the MetaEditor by clicking on "Tools" and selecting "MetaQuotes Language Editor" from the dropdown menu. The MetaEditor is where we create our expert advisors, as well as scripts and indicators for MetaTrader.

To create a new expert advisor, we click on the "New" button in the top left corner of the MetaEditor. In the wizard that appears, we select the first option and click "Next." We can then give our EA a name, such as "First EA," and click "Next" again. We skip selecting any additional options and proceed by clicking "Finish."

Now we have the initial code for our EA. To start, we clean up the code by removing unnecessary comments, such as the gray comments that provide no functionality to the code itself. We delete the first five lines and some other unnecessary lines, as per our preference.

Before we begin coding, let's take a moment to consider what we want our EA to do. For this video, our goal is to have the EA open a buy trade at a specific time and close it at another predetermined hour of the day. To achieve this, we need two input variables: one for the open time and another for the close time.

Returning to the MetaEditor, we declare these two input variables under a new section called "Variables." We use the "input" keyword to specify that these variables can be changed from outside the code. We set their types as integers since we want to enter specific hour values. For example, we can name the variables "openHour" and "closeHour."

After declaring the variables, we compile the code to ensure there are no errors. If everything is correct, we can see that there are no error messages in the toolbox.

Next, we switch back to the MetaTrader platform and drag our EA onto any chart. We can see the EA's name, version, and link in the navigator under "Expert Advisors." By expanding the EA, we can access the input variables and change their values without modifying the code.

Now, let's move on to the "OnTick" function, which is called every time the price changes. We want to check if we have reached the open time specified by the user. To do this, we need to retrieve the current time of the symbol and the server. We create a variable called "time" of type "datetime" and use the "TimeCurrent" function to assign the current time to it.

With the current time stored in our "time" variable, we can now check if it matches the open time. We use an "if" statement to compare the "openHour" variable with the hour component of the current time ("time.hour"). If the condition is true, we enter the "if" block.

Inside the "if" block, we open a position using the "OrderSend" function. We specify the symbol, trade direction (buy), lot size (1 lot), and ask price as parameters. Additionally, we set the stop loss and take profit values as per our preferences.

After compiling the code and running a backtest using the MetaTrader strategy tester, we observe that the EA opens a position at the specified open time. However, we notice that multiple positions are opened due to subsequent price movements triggering the "OnTick" function again.

To prevent multiple positions from being opened, we introduce a boolean variable called "isTradeOpen" to keep track of whether a trade is already open. Initially, we set the value of "isTradeOpen" to false. Before opening a new position, we check if "isTradeOpen" is false. If it is, we proceed to open the position and set the value of "isTradeOpen" to true. This way, even if the "OnTick" function is triggered multiple times, it will only open a new position if there isn't already an open trade.

After implementing this logic, we compile the code again and run a backtest. This time, we observe that the EA opens a position at the specified open time and does not open any additional positions until the previous one is closed.

Moving on to closing the trade at the specified close time, we need to introduce another check in the "OnTick" function. After opening the position, we compare the current time with the close time specified by the user. If they match, we enter an "if" block.

Inside the "if" block, we close the trade using the "OrderClose" function. We provide the ticket number of the position to close, as well as the lot size and bid price as parameters. Additionally, we can set additional parameters such as stop loss and take profit values if desired.

We compile the code again and run a backtest to verify that the trade is closed at the specified close time. During the backtest, we can check the trade history to ensure that the positions are opened and closed according to the specified times.

We have successfully created our first EA for the MetaTrader trading platform. The EA is designed to open a buy trade at a specific open time and close it at a predetermined close time. We have implemented input variables to allow customization of the open and close times without modifying the code. By introducing checks and variables, we ensure that only one trade is opened at a time and that it is closed at the specified close time.