MQL5 Templates
repository·master·Indexed 42 days ago
https://github.com/sibvic/mq5-templatesA collection of templates and snippets designed to accelerate the development of MQL5 indicators and Expert Advisors (EAs), specifically optimized for conversions from PineScript via the Trade Script Convertor. It includes a comprehensive Action system (IAction), a logical Condition hierarchy (ICondition), a Grid system for data display, and money management strategies (IStopLossStrategy), as well as PineScript-style array implementations.
What's inside mq5-templates
- This collection provides a set of MQL5 functions designed to mimic the syntax and behavior of PineScript (TradingView). These functions allow developers to write MetaTrader 5 code using familiar patterns from PineScript, covering string manipulation, strategy-to-indicator conversions, symbol information, timeframe handling, extended mathematics, and plotting shapes.
Use the mq5-templates for MQL5 development
masterThis repository provides foundational templates for MetaTrader 5 (MT5) development using MQL5. It includes base structures for Expert Advisors (EAs), Indicators, and specialized components like heatmaps to accelerate the development process.Use abstract stream implementations for MQL5
masterThe
Streams/Abstractdirectory provides base abstract classes that implement specific stream interfaces. These classes are designed to be extended to create concrete stream implementations for different data types in MQL5/MT5.Available abstract implementations include:
AFloatStream: ImplementsIFloatStream.ADateTimeStream: ImplementsIDateTimeStream.AColorStream: ImplementsIColorStream.AStringStream: ImplementsIStringStream.TAStream: ImplementsTIStream.
Use Enum snippets for MQL5 development
masterThis collection provides Visual Studio Code snippets for common MQL5 enumerations. These snippets allow for rapid insertion of standard enum types used in MetaTrader 5 development, such as order sides, position sizing, stop/limit types, and moving average types.Use the SARStream indicator template
masterTheSARStreamtemplate provides a non-moving average indicator implementation based on the Parabolic Stop and Reverse (PSAR) stream logic. It is designed for use within the MQL5/MT5 environment to identify trend reversals or volatility-based stream signals.Use MoneyManagementFunctions for money management objects
masterTheMoneyManagementFunctionsmodule provides a collection of functions designed to interact with and manage money management objects within the MQL5 environment.Available MQL5 Snippets and Utilities
masterThe repository provides a collection of specialized snippets and utility classes for MQL5 development, including:
- Data & Information:
InstrumentInfo(instrument details),Syminfo(PineScript-style syminfo functions), andHeatMapValueCalculator(heatmap logic). - Iteration:
TradesIterator(active trades),OrdersIterator(active orders), andClosedTradesIterator(historical trades). - Trading Logic:
TradingCalculator,Condition,MoneyManagement,TrailingController,BreakevenController, andEntryPositionController. - Order Management:
MarketOrderBuilder,OrderBuilder(for creating order commands),TradingCommands,TradeController, andOrderHandlers(actions for new orders). - Visuals & PineScript Conversion:
AlertSignal(drawing arrows on conditions),PlotChar(PineScript-style plotchart), andPineScriptUtils(converting Pine Script to MQL5).
- Data & Information:
Use PineScript-style string functions (Str)
masterThestr.*function group provides string manipulation capabilities similar to PineScript's string handling within the MQL5 environment.Access symbol information with SymInfo
masterThesyminfo.*function group provides access to metadata and properties of the current trading symbol, mirroring PineScript'ssyminfonamespace.Create logical combinations with AndCondition and OrCondition
masterYou can combine multiple conditions using logical operators:
AndCondition: Returnstrueonly if all constituent conditions returntrue.OrCondition: Returnstrueif at least one of the constituent conditions returnstrue.NotCondition: Inverts the result of another condition (logical NOT).
Use LabelStream for streams of labels
masterTheLabelStreamprovides a way to handle a stream of label objects in MQL5.Draw trend lines with Polyline and PolyLinesCollection
masterFor drawing complex trend lines, use the following:
Polyline: An object for drawing trend lines. It manages its own creation, deletion, and redrawing using reference counting support.PolyLinesCollection: A collection manager that handles the creation, deletion, and organization of polyline objects across multiple collections, providing automatic cleanup and memory management.