S1Service

Algorithmic trading systems

Valeron builds expert advisors for MetaTrader 4 and MetaTrader 5, covering strategy logic, risk controls, and order execution.

  • MetaTrader 4
  • MetaTrader 5
  • MQL4
  • MQL5

Expert advisor, bar by bar

Illustrative

  1. Signal
  2. Risk check
  3. Order

An illustrative animation. Generated candles form one bar at a time. When a bar closes, the expert advisor looks for a signal, runs the risk check, and sends an order only when both pass. The bars are not market data.

The chart and the pipeline are illustrative. They show generated bars, not market data.

01Anatomy

Three parts of an expert advisor

An expert advisor is a program that MetaTrader runs on a chart. Each decision it makes passes through the same three parts, in the same order.

  1. Illustrative

    01Signal

    Strategy logic

    The rules that decide when the expert advisor acts: the conditions that open a position, the conditions that close it, and when they are checked, on every tick or once per closed bar.

    • Entry and exit conditions
    • Checked per tick or per bar
    • Parameters set as inputs
  2. 02Risk check

    Risk controls

    The checks that decide whether an order may go out at all, and at what size. They run before every order, whatever the signal says.

    • Size from equity and stop distance
    • Spread limit at entry
    • Symbol volume limits
    • Limit on open positions
  3. 03Order

    Order execution

    The order goes to the trade server with its stop level attached. The result is checked, and a rejected request is handled and recorded, never ignored.

    • Stop level sent with the order
    • Result code checked
    • Rejections recorded

02Integrations

Broker and platform integrations

The work extends past the expert advisor itself, to broker and platform integrations for order routing, market data, and account reporting.

  • I/01

    Order routing

    The path an order takes from the strategy to the broker: through the trading platform, or through an interface that the broker provides.

  • I/02

    Market data

    Ticks, quotes, and bar history for the strategy to read, from the terminal or from another source, checked before they are used.

  • I/03

    Account reporting

    Balance, equity, open positions, and trade history, collected from the account and turned into reports.

03Platforms

MetaTrader 4 and MetaTrader 5

Valeron builds expert advisors for both platforms. Each one has its own language and its own trade functions.

MetaTrader 4 and MetaTrader 5 side by side
ItemMetaTrader 4MetaTrader 5
LanguageMQL4MQL5
Source file.mq4.mq5
Compiled file.ex4.ex5
Tick handlerOnTick()OnTick()
Open tradesOrders, one ticket eachPositions, netting or hedging
MQL4OrderGate.mq4Illustrative
#property strict

input double Lots       = 0.10;  // volume per order
input int    StopPoints = 250;   // stop distance in points
input int    Slippage   = 3;     // accepted slippage in points
input int    Magic      = 4107;  // marks the orders of this expert

void OnTick()
  {
   if(CountOwnOrders() > 0 || !EntrySignal())
      return;

   RefreshRates();
   double stop = NormalizeDouble(Bid - StopPoints * Point, Digits);
   int ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage,
                          stop, 0.0, "entry", Magic, 0, clrNONE);
   if(ticket < 0)
      Print("OrderSend failed, error ", GetLastError());
  }

int CountOwnOrders()
  {
   int count = 0;
   for(int i = OrdersTotal() - 1; i >= 0; i--)
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)
         && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
         count++;
   return(count);
  }

Excerpt. Before it sends an order, the expert counts its own open orders by symbol and magic number. The stop level goes with the order, and a failed request is reported with its error code.

04Contact

Discuss an expert advisor

The contact form is the only contact channel. Valeron replies to the address given in the form.

Send a message

Other services

Service 03

SaaS product engineering

Software products taken from a written specification to a running, multi-tenant service.