Service 02
.NET and C# backend and full-stack development
Backend services and APIs in .NET and C#, from the data model through to deployment.
S1Service
Valeron builds expert advisors for MetaTrader 4 and MetaTrader 5, covering strategy logic, risk controls, and order execution.
Expert advisor, bar by bar
Illustrative
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
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.
Illustrative
01Signal
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.
02Risk check
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.
03Order
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.
02Integrations
The work extends past the expert advisor itself, to broker and platform integrations for order routing, market data, and account reporting.
I/01
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
Ticks, quotes, and bar history for the strategy to read, from the terminal or from another source, checked before they are used.
I/03
Balance, equity, open positions, and trade history, collected from the account and turned into reports.
03Platforms
Valeron builds expert advisors for both platforms. Each one has its own language and its own trade functions.
| Item | MetaTrader 4 | MetaTrader 5 |
|---|---|---|
| Language | MQL4 | MQL5 |
| Source file | .mq4 | .mq5 |
| Compiled file | .ex4 | .ex5 |
| Tick handler | OnTick() | OnTick() |
| Open trades | Orders, one ticket each | Positions, netting or hedging |
#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
The contact form is the only contact channel. Valeron replies to the address given in the form.
Other services