Guarda come scaricare robot di trading gratuitamente
Ci trovi su Twitter!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Librerie

AttachExpert: attach an EA with inputs to a chart from code - libreria per MetaTrader 5

Mohamed-amine Baddir
Mohamed-amine Baddir
Sviluppo Expert Advisor per MetaTrader 5 e li testo correttamente prima che tu li utilizzi per fare trading.
Cosa faccio:
- Trasformo la tua strategia, il tuo script TradingView o le tue regole scritte in un Expert Advisor MT5 pulito
Visualizzazioni:
114
Pubblicato:
\MQL5\Include\ \MQL5\Scripts\
Freelance MQL5 Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

AttachExpert.mqh attaches an Expert Advisor to a chart from MQL5 code, with the inputs you choose and with "Allow Algo Trading" on or off. MQL5 has no function for this; the library writes a template with an <expert> block and applies it with ChartApplyTemplate().

A test EA attached on four timeframes reports the inputs it received

Usage

#include <AttachExpert.mqh>

long chart = ChartOpen("EURUSD", PERIOD_H1);
CExpertInputs in;
in.SetInt("InpValue", 42);
in.SetDouble("InpRatio", 1.25, 2);
in.SetString("InpText", "hello world");
in.SetBool("InpFlag", true);
AttachExpert(chart, "MyFolder\\MyEA", in, true);   // MQL5\Experts\MyFolder\MyEA.ex5
  • Inputs that you do not set keep their default values.
  • The template is applied asynchronously. By default AttachExpert() waits up to 10 seconds until the EA runs on the chart (CHART_EXPERT_NAME); pass waitMs = 0 to return at once, for example from an Expert Advisor.
  • Do not apply it to the chart of the calling Expert Advisor: the template would replace the caller.
  • Whether the attached EA can trade also depends on the AutoTrading button of the terminal.

Example

The script AttachExpertExample.mq5 opens a chart and attaches the Moving Average example EA (Experts\Examples\Moving Average) with chosen inputs. Put AttachExpert.mqh in MQL5\Include and the script in MQL5\Scripts.

Checked

A test EA attached on M15, H1, H4 and D1 charts reported the inputs it received (int, double, string with a space, bool) and whether it was allowed to trade; all matched (picture 1).

News Lines Utility – Economic Calendar Lines and Event Panel News Lines Utility – Economic Calendar Lines and Event Panel

Short description (for the "Short description" field) Shows economic news events directly on your chart as colour-coded vertical lines with tooltips, plus a draggable event panel with upcoming and recent releases. Works on every symbol and timeframe, with filters for impact level and instrument groups (Gold & Silver, Forex Majors, Indices, Oil & Gas).

Margin Call Radar Margin Call Radar

Read-only panel that shows the distance to margin call and stop out in money, percent of equity and points, plus adverse price and equity shock scenarios. Hedge-aware, does not trade.

FxCraft Example EA – MA Cross FxCraft Example EA – MA Cross

Educational Expert Advisor: moving average crossover with clean, commented MQL5 code – margin, volume, stop level and spread checks, order retries. Demo accounts and Strategy Tester only.

FxCraft Example EA – Bollinger Bands mean reversion FxCraft Example EA – Bollinger Bands mean reversion

Educational Expert Advisor: Bollinger Bands return to the mean with an optional RSI filter and trading hours. Clean, commented MQL5 code with margin, volume and stop level checks. Demo and Strategy Tester only.