1.2 KiB
1.2 KiB
Some Usefull Tutorials
Open Order
for opening a sample order in mql4 follow following syntax:
// buy => ASK Price ... sell => BID Price ...
void OnTick() {
//
if (OrdersTotal() > 0) {
return;
}
//
// we are on bullish candle ...
if (close[1] > open[1]) {
//
OrderSend(
_Symbol, // Symbol ...
OP_BUY, // Operation ...
0.1 // Lot Size ( Volume ) ...
Ask, // Open Order Price ...
3, // tolerance ...
Ask - 300 * _Point, // SL ...
Ask + 150 * _Point, // TP ...
NULL, // Trade Comment ...
0, // Magic Number (user unique number) ...
0, // Expiration ...
Green // Arrow Line ...
);
}
}
Counting Open Buy Positions
int CountOpenBuyOrders() {
//
int result = 0;
//
for (int i = OrdersTotal() - 1; i >= 0; i--) {
//
OrderSelect(i, SELECT_BY_POSITION, MODE_TRADES);
//
string orderSymbol = OrderSymbol();
//
if (
orderSymbol == _Symbol &&
OrderType() == OP_BUY
) {
result++;
}
}
//
return result;
}