MQL5 Algo Trading
393K subscribers
2.59K photos
2.59K links
The best publications of the largest community of algotraders.

Subscribe to stay up-to-date with modern technologies and trading programs development.
Download Telegram
An effective edit of the Mod_ATR_Trailing_Stop, a reliable algorithm initially crafted by Scriptor, has recently been completed. By tweaking the code, the number of buffers has been successfully reduced from two to one, resulting in a single line output. This modification aligns this iteration of code more closely with Bruce Hellstrom's original MT4-LevelStop-Reverse.v2, known for its efficiency and utilizing just one buffer.

With the ripple effects of this edit extending across platforms, a drumroll seems to be in order for MT5 users. Thanks to these revisions, this version of the indicator might be the closest MT5 users can get to incorporate an indicator akin to Bruce Hellstrom's MT4-LevelStop-Reverse.v2.

Those seeking to brush up their skills or just satisfy their curiosity should head towards https://www.mql5.com/en/code/20423 to grasp the intricacies of the original code. It ...

Read More
πŸ‘9πŸ€”2❀1
Developing a GUI library in the context of MetaTrader 5 is no minor feat, and it's certainly not the first task typically associated with this platform. However, it can be a rewarding challenge, paving the way for enhanced control over projects, customised capabilities, and valuable learning experiences.

GUI libraries enable tracking and modifying object properties, such as triggering events like movements or color changes. This is usually organised in a tree structure often manage through a 'program class', a placeholder coordinating operations that avoid unnecessary repetition and ensure children are created timely.

The fundamental building block of any GUI library is the 'element class', taking care of the crucial information about position, size, and relations with other elements. Handling the relations between objects involves defining functions for adding child elements and se...

Read More
πŸ‘7❀2πŸ‘¨β€πŸ’»1
In the realm of programming, the intricacy of setting the maximum rollback size is critical. To address this, simply locate the upper-left corner of the chart for the specific window. This action triggers the indicator to promptly display the proximate reversal levels as well as their corresponding probability. Such process bolsters the understanding between developers and their tools, hence, ultimately crafted for efficiency and functionality. The aforementioned method exemplifies the harmony between user control and technological sophistication, a key aspect in this field of work.

Read More
πŸ‘5❀1πŸ€”1
The application of category theory to finance, particularly its adaptation for valuation and portfolio allocation, is yet unexplored terrain; especially in the realm of stock valuation where key stock metrics are viewed as objects in a category. This theoretical approach could provide unique insights into financial trends and risk evaluation.

In time series forecasting, moving averages are key. While occasionally overlooked for being too simplistic, their foundational role in other indicators, such as Bollinger Bands and Moving Average convergence divergence (MACD), makes them indispensable. Less volatile view of price actions presented by moving averages can dim double-edged sword of market white noise.

Natural transformations in category theory bridge the gap between related data sets of varying dimensions. These enable the comparison of 'simple' series of raw prices with 'compoun...

Read More
πŸ‘5πŸ€”1
In today's technical discussion, a closer look is taken at the robust indicator tool based mainly on analyses of pricing channels and asset volatility. Functioning as a trend predictor, this tool excels in generating accurate signals embodied in arrow form.

These signals serve as pivotal markers for traders, hinting at trend reversals. In turn, practitioners can base their strategic trading decisions upon these timely cues. The confluence of price channel dynamics and asset volatility analysis gives this indicator its potency, making it an essential instrument in any trader's analytical toolbox.

An enhanced understanding of market trend shifts can be the determining factor between successful and unfruitful trading outcomes. Using reliable signal generators such as this, traders gain a valuable edge in forecasting and strategizing actions in the dynamic trading landscape.

Read More
πŸ‘7❀1πŸ†1
The Go-Explore algorithm introduces a leading-edge approach to reinforcement learning problem-solving. Distinctively focusing on finding relevant states and actions within the state space, rather than directly tackling the target problem, this method promotes efficient learning by allowing for the revisitation and remembering of promising state spaces. Building and testing separate Expert Advisors sequentially, each performing a unique algorithm task with a common objective of policy learning constitutes the structure of the process. Collected data results from the short-term strategy tester reveals promising outcomes, demonstrating exceptional balance sheet growth metrics, and trade profitability. However, extensive testing and training over a longer timeline are necessary before deployment into real-world account use.

Read More
πŸ‘7
Unveiling the "Martin Gale Breakout" strategy in Forex trading landscape. This Expert Advisor (EA) ingeniously couples a breakout trading approach with Martin Gale's money management elements, significantly optimizing trading performance.

Key input parameters include TakeProfPoints– setting a Take Profit level in points for each trade, BalancePercentageAvailable which defines the percentage of the account balance used for trading, and TP_Percentage_of_Balance and SL_Percentage_of_Balance for determining the account balance percentages allocated for Take Profit and Stop Loss respectively. The Start_The_Recovery feature regulates the activation of recovery measures. With TP_Points_Multiplier, creating flexible profit-taking strategies becomes seamless. The unique identifier MagicNumber allows the EA to manage its trades independently.

The strategy offers numerous advantages. Its mast...

Read More
πŸ‘4
In the preceding article, certain amendments were made but there's an error yet to be addressed. Today, let's focus on modifying the control indicator to apply only to a chart with a specific symbol.

Step one necessitates linking the control indicator to the symbol for market replay. The function executed during initialization is designed to call our indicator, allowing for seamless removal. Consider that once we remove it from the chart, MetaTrader 5 generates the DeInit event, enabling the OnDeInit function, thus leading to the removal of the indicator.

If any alterations were detected in the code compared to the previous article, be advised that the last article tackled a different objective. Mid-way, yet another issue was discovered necessitating adjustments to the code independently from the previous fixes.

Encountering such roadblocks, modifications and workarounds are par...

Read More
πŸ‘3
Presenting the "Martin Gale Breakout" strategy - an intelligent Expert Advisor (EA) for Forex market trading. It converges a breakout trading methodology with Martin Gale's principles of money management, thereby enhancing trading efficiency.

The EA offers a broad spectrum of customizable Input Parameters such as TakeProfPoints to set the Take Profit level for each trade and BalancePercentageAvailable to designate how much of your account balance to use for trading. Also, parameters like TP_Percentage_of_Balance, SL_Percentage_of_Balance allows you to determine the account balance percentages for Take Profits and Stop Losses. Moreover, TP_Points_Multiplier provides an option to multiply Take Profit points, customizing profit-making strategies.

Recovery is significant in trading. Start_The_Recovery, a crucial parameter manages the recovery process, controlling the timing and manner o...

Read More
πŸ‘5❀1
Latest advancement from the coder's desk: Rectifying minor faults and enhancing tests for the replay system, catering to steadfast stability. A configuration file has also been introduced into the system, aiding in more manageable operations. Peak system stability continues to remain an unfulfilled agenda, with solutions both simple and complex remaining to be implemented.

On one hand, present improvements feature the incorporation of a control indicator that remains on the chart even after loading the template. The new feature ensures the replay service stops immediately upon the removal of the indicator. On the other hand, the system ensures the control indicator stays intact, even in cases of partial deletion.

The code has also been tweaked to tackle situations where the system begins opening charts of the same symbol, creating a bottleneck scenario. The enhanced function ensure...

Read More
πŸ‘3
In a recent technical exploration, attention was focused on the MarketOpenHours.mqh file and its functionality. This particular file examines the discrepancy between Market Open Hours and the server time assigned by the broker. It's worth noting that the input required here is solely the Symbol name in string format.

Following the processing of this information, an output is produced: a boolean value indicating whether the market is open (true) or closed (false). The variance in open times on divergent weekdays is a point of keen interest and can be seen in the associated image, which demonstrates the open hours for the broker DarwinEx regarding the symbol EURUSD.

Technical specifications of the include file incorporate an initial examination of the weekday (Monday through Friday). Such provision permits the potential for trade opening and stop trailing during this timeframe. A chec...

Read More
πŸ‘3❀1
Unveiling a possible resolution to the exploration problem in reinforcement learning – introducing Self-Supervised Exploration via Disagreement. This algorithm, based on a self-learning approach, enables the agent to generate intrinsic rewards by interacting and getting information from its environment. Unlike other algorithms, it incorporates multiple models interacting with the environment, producing varying predictions.

If the models disagree, it's regarded as an 'interesting' event, making the agent more determined to uncover that space in the environment. As the agent explores novel environment areas, it's able to offer more accurate reward predictions. It increases efficiency and reduces reliance on potential limited or costly external rewards, making it particularly beneficial in real-world applications.

The discrepancy in forecasts is used as an intrinsic reward for policy...

Read More
πŸ‘5❀1
Access the treasure trove of coding examples housed in the official documentation, whether the goal is to learn, create a foundation for more complex programs, or simply improve personal codebases for more simplified, reusable solutions.

Find inspiration in the reworked codes available on Mql5 iFunctions, which are now optimized for recycling. Feedback is appreciated. Prospective users are encouraged to compare these codes with those from the original document and provide constructive comments.

For beginners in coding, a variety of basic codes have been provided, which include ADX, Alligator, AMA - Adaptive Moving Average, ATR - Average True Range, Bands Bollinger, and Ichimoku among others. These have been designed to fast track learning and provide a chase for quick evolution.

For those looking to understand calculations of indicators without applying Mql5 iFunctions, look no ...

Read More
πŸ‘2❀1
In this series, we have been focusing on the non-operational section of the MQTT protocol. Now, we are moving on to the operational part, which involves dealing with packets sent from the server. Our client needs to identify the server packet type and determine the appropriate behavior based on the client's state. To do this, we need to identify the server packet type in the first byte of the response. If it is a CONNACK packet, we must read its Connect Reason Code and react accordingly.

When our client requests a connection with the server, it must inform the server about desired capabilities, such as authentication and session preferences. This is done by setting bit flags in the Connect Flags field. These flags represent boolean values, with true or false indicating the desired capabilities. For example, the Clean Start flag indicates whether the server should discard any existing...

Read More
πŸ‘2
Detailing Symbol Input Classification: This function accepts the symbol of a financial instrument, its primary function is to ascertain the filling policy. The method employed here is SymbolInfoInteger to accrue the filling policy information for the given symbol. The information is stored numerically in a variable coined 'filling'.

Differentiation of Filling Methods: The numerical value encapsulated in 'filling' is subsequently compared with constants symbolizing the array of filling policies, such as "Fill or Kill" (SYMBOL_FILLING_FOK), "Immediate or Cancel" (SYMBOL_FILLING_IOC), and Return (SYMBOL_FILLING_RETURN).

Deciphering the Filling Policy Protocol: Post comparison, the function identifies the type of the filling policy. If it links with "Fill or Kill," it indicates ORDER_FILLING_FOK. In the case it links up with "Immediate or Cancel," it signals ORDER_FILLING_IOC. Failing...

Read More
πŸ‘8❀1
πŸš€ New Article Alert! πŸ“š
In this article, we explore the implementation of financial time series forecasting based on neural networks using PyTorch Lightning and PyTorch Forecasting framework through the MetaTrader5 trading platform. We provide detailed explanations on the libraries we utilized, including PyTorch Lightning and PyTorch Forecasting, highlighting their benefits and features for professional AI researchers and machine learning engineers.

πŸ“š In this post, we introduce several important Python libraries for time series forecasting. We begin with PyTorch Lightning, a powerful framework designed for flexibility and scalability. With its separation of academic and engineering code, PyTorch Lightning streamlines and enhances code reusability, maintenance, and logic comprehension.

πŸ” We also discuss PyTorch Forecasting, a specialized library for time series forecasting. Buil...

Read More
πŸ‘3❀1
πŸ“£ Exploring the Implementation of Category Theory in MQL5!

Implementing Category Theory in MQL5 can be an intimidating task, especially with the lack of easily accessible material on the subject. But fear not! We are here to make this topic more approachable for traders. In this article, we will highlight the concept of horizontal composition of natural transformations.

In our previous article, we discussed the vertical composition of natural transformations. This time, we will extend the moving average time series horizontally by introducing a third category: the double exponential moving average. Our variant of this indicator is a moving average of a moving average, making it a valuable tool for analysis.

Similar to the previous article, we will have two functors between the categories, each with its own moving average period. The natural transformation between these functor pai...

Read More
πŸ”₯3πŸ‘1
In the financial industry, traders often aim for high returns; however, this also increases risk. Therefore, risk-adjusted returns are a vital performance criterion. There are diverse metrics for this, each with pros and cons. For instance, the Sharpe ratio is a common measure, but it applies unrealistic conditions on return distribution, prompting alternatives.

The aim here is to outline the implementation of such alternative risk-return measures and generate hypothetical equity curves for analysis. The base data for the simulated trading strategy are the SP 500 - no specific trading rules are utilized, rather random numbers generate equity curves and the corresponding return series.

An application implemented as a Metatrader 5 (MT5) Expert Advisor graphically displays three equity curves – the benchmark red curve can be adjusted with the initial capital and defines the blue and ...

Read More
πŸ‘5
Understanding the application of the Double Bollinger Band strategy in the forex market can filter entries and departures. The essential aim is to initiate Buy or Sell trades when the forex price fluctuates beyond the 3Οƒ (3-standard deviation) in the respective direction. The 2Οƒ (2-standard deviations) standard deviation level of the Bollinger Bands are also taken into account for decision making.

Let's address the default parameters:
The 2Οƒ Bollinger Bands (20,2) signifies the simple moving average of 20 and the standard deviations at 2. The 3Οƒ Bollinger Bands (20,3) indicates the simple 20 moving average and 3 as the standard deviations.

For initiating a long entry, it is suggested to open a Buy order when the following conditions are adhered to:
1) The Ask price must surpass the 3Οƒ upper Bollinger Band (BB3UP).
2) Ensure the current price falls within the range of the 2Οƒ uppe...

Read More
πŸ‘3
Following the examination of various topics in category theory applicable beyond the academic sphere, including sets & morphisms, ontology logs, functors, and natural transformations, this article moves forward by addressing possible applications of natural transformations in time series forecasting.

The need for such forecasting arises when a startup company creates a database for tracking customer purchases and notices substantial redundancy in the product column, highlighting popular products. Responding to this, the company decides to log more product-related data to better discern customer preferences and potentials for new product development. This could lead to partitioning the existing product column into parameters like version, subscription mode, and build name or the payment column into payment mode, currency, and payment amount.

Any alterations to the data structure mig...

Read More
πŸ‘3
Working on a Sunday isn't rare in the realm of software development. The highlight of today’s work is the 'Awesome Oscillator' that's now available in the open-source codebase, in addition to the 'Adaptive Moving Average' and the 'Alligator'. This new embodiment of the iAO function provides better flexibility by offering increased adjustment parameters on moving averages.

Breaking the barriers of a single-function tool, the revamped iAO function now takes into account periods, methods, and application. The aim is to present you with a code that is simple, clear, and effectively embodies basic concepts. The additional bonus is its potential to be a perfect starting point for customizing it further based on individual requirements.

Feel free to reach out for detailed understanding or for suggesting ideas for free development. There's also a collection of free indicator codes designed ...

Read More
πŸ‘5