The code ought to read at least as syntactically-correct:
{ // outer context missing
// . // outer context missing
// .. // outer context missing
// ... // outer context missing
RefreshRates(); // a life-saving jacket while // outer context missing
if ( OrdersTotal() == 0
&& Bid <= iOpen( _Symbol, PERIOD_D1, 0 )
- ( 10 * _Point )
)
{ OrderSend( _Symbol, // <symbol>
OP_BUY, // <op>
1.0, // <volume>
Ask, // <XTO_price>
0, // <slippage_allowed>
0, // <autoXTO_SL>
NormalizeDouble( Ask + 10 * _Point, // **ALWAYS**
_Digits // NORMALIZE XTO levels
), // <autoXTO_TP>
NULL, // <commentSTRING>
12321, // <MagNUM>
0, // <expireSECONDs>
clrBlue // <arrowCOLOR>
);
}
// ...
// ..
// .
}
Epilogue
There is no need to add any additional constructs for the given logic. MetaTrader Terminal 4
will dispatch the OrderSend()
details to the remote MetaTrader 4 Server
and if your values do meet the Broker-side Terms & Conditions, you will get such trading position opened ( exposed to Market Risk, while being fully backed & covered by your Equity ).
At the same time, the MetaTrader 4
Server
will ensure, that no other code is required per-se for such position to become <autoXTO_TP>
-terminated on the very moment the FX-Market reaches the predefined TP
-termination level.
While the above is true, it is however fair to say that professional-grade algo-trading systems have many other utility-services, attached to the core trading logic. Just to have some idea, designs with about 80.000 ~ 100.000 SLOC
s are common in production-grade systems.
Where to go from here?
It might be helpfull to re-read the MQL4
documentation ( let me put this a bit clearer -- the localhost-installed and updated release of the actual-release-of-New-MQL4
language ... not the static and "old" texts on web, as the syntax-rules & context-specific limits creep a lot ... still do, ref. below )
rather
than
to headbang again into another issues with "old"-MQL4
syntax code-snippets.
The MQL4
language evolves a lot during the last few years and lot of web-posted code-snippets have lost their explanatory value, due to many shifts in paradigm, that happened "inside the language" or due to code-execution platform changes.
Bitter? Yes.
Painfull? Yes.
This is the Life, nevertheless...