i would like to write a code for a hedge strategy in one currency and stop open
when, for example, buy OP are more then sell OP, so i need to write something like,
"if totalorder of OP_BUY > totalorders of OP_SELL"
any idea?
- Bulk Operations - Trade - MetaTrader 5 for iPhone
- Opening and Closing Positions - Trade - MetaTrader 5 for iPhone
- Bulk Operations - Trade - MetaTrader 5 for Android
yocy1:
i would like to write a code for a hedge strategy in one currency and stop open when, for example, buy OP are more then sell OP, so i need to write something like, "if totalorder of OP_BUY > totalorders of OP_SELL" any idea?
i would like to write a code for a hedge strategy in one currency and stop open when, for example, buy OP are more then sell OP, so i need to write something like, "if totalorder of OP_BUY > totalorders of OP_SELL" any idea?
int BuyCnt = 0; int SellCnt = 0; int BuyStopCnt = 0; int SellStopCnt = 0; int BuyLimitCnt = 0; int SellLimitCnt = 0; int cnt = OrdersTotal(); for (int i=0; i < cnt; i++) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; //if (OrderSymbol() != Symbol()) continue; //if (OrderMagicNumber() != Magic) continue; int type = OrderType(); if (type == OP_BUY) BuyCnt++; if (type == OP_SELL) SellCnt++; if (type == OP_BUYSTOP) BuyStopCnt++; if (type == OP_SELLSTOP) SellStopCnt++; if (type == OP_BUYLIMIT) BuyLimitCnt++; if (type == OP_SELLLIMIT) SellLimitCnt++; }MQL How-To Guide
Your Ideas in Expert Advisors

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register