Hey guys,
I need help on coding an order should only be opened between the start of the hour and 30 minutes into the hour. If it closes within 30 minutes due to take profit or stop loss it should not open another order until the beginning of the next hour and end of 30 minutes. And so on. Anyone out there who can help on this please.
- [Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2.
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- [ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5.
- Usually people who cannot code do not receive free help on this forum.
- If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
- If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free).
- Finally, you also have the option to hire a programmer in the Freelance section.
- mahlon84: Anyone out there who can help on this please.
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
No free help (2017) -
When in doubt, think.
void OnTick(){ datetime now=TimeCurrent(); static datetime beginTrading=0; if(beginTrading > now) return // Wait for the next half hour. if not trade condition return OrderSend int ps=PeriodsSecond(PERIOD_M30); // 1800 second datetime halfHour = now - now % ps; // Last half hour. beginTrading=halfHour + ps; // Wait for the next half hour. }
- mahlon84: Mql4 code to check if current order has been closedYour post's title doesn't match your question. “Current order” and “closed” in the same sentence makes no sense. Just count your open orders.
#ifdef __MQL4__ enum TradeOperation{ // Same as OP_xxx except a proper enumeration. eTO_BUY, eTO_SELL, eTO_BUYLIMIT, eTO_SELLLIMIT, eTO_BUYSTOP, eTO_SELLSTOP, eTO_BALANCE, ///< (6) May occur in history pool. eTO_CREDIT}; ///< (7) May occur in history pool. #define ENUM_ORDER_TYPE TradeOperation // Override MT4 compiler. #endif int count_orders(int mn=EMPTY, ENUM_ORDER_TYPE op=WRONG_VALUE){ return count_orders(_Symbol, mn, op); } int count_orders(string symbol, int mn=EMPTY, ENUM_ORDER_TYPE op=WRONG_VALUE){ int count=0; for(int i=OrdersTotal(); --i >0;) if( select_order(iPos, SELECT_BY_POS) && (OrdeMagic() == mn || mn==EMPTY) && (OrderType() == op || op==WRONG_VALUE) && OrderSymbol() == symbol ) ++count; return count; }
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