Yay!
//+------------------------------------------------------------------+ //| Returns the "undefined" state of the trading environment | //+------------------------------------------------------------------+ bool IsUncertainStateEnv(const string symbol_name,const ulong magic_number) { if(MQLInfoInteger(MQL_TESTER)) return false; int total=OrdersTotal(); for(int i=total-1; i>WRONG_VALUE; i--) { if(OrderGetTicket(i)==0) continue; if(OrderGetInteger(ORDER_TYPE)>ORDER_TYPE_SELL) continue; if(OrderGetInteger(ORDER_MAGIC)!=magic_number) continue; if(!OrderGetInteger(ORDER_POSITION_ID) && OrderGetString(ORDER_SYMBOL)==symbol_name) return true; } return false; } //+------------------------------------------------------------------+ //|| Fills position ticket arrays| //+------------------------------------------------------------------+ bool FillingListTickets(const uint number_of_attempts) { //--- Checking the state of the environment int n=0,attempts=int(number_of_attempts<1 ? 1 : number_of_attempts); while(IsUncertainStateEnv(symb,InpMagic) && n<attempts && !IsStopped()) { n++; Sleep(sleep); } if(n>=attempts && IsUncertainStateEnv(symb,InpMagic)) { Print(__FUNCTION__,": Uncertain state of the environment. Please try again."); return false; } //--- //+------------------------------------------------------------------+ //| Expert tick function| //+------------------------------------------------------------------+ void OnTick() { //--- Checking zero prices if(!RefreshRates() || Point()==0) return; //--- Filling of item ticket lists int positions_total=PositionsTotal(); if(prev_total!=positions_total) { if(FillingListTickets(num_attempts)) prev_total=positions_total; else return; }
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
SerialMA_EA:
The Expert Advisor is based on a dynamic moving average.
Author: Scriptor