Which EA model is best to use?

 
Which model to use Which working model is the best for running the EAs?

- approach 1: wait for each incoming tick in order to open/close/modify orders

int start()

{

// do the work here

// then go away, until the next tick comes in.

}


- approach 2: EA is always running and periodically asks fresh information from server in order to open/close/modify orders

int start()

{

__double __ask=0;

__while(!IsStopped())

__{

____Sleep(5000); // sleep sometime

____if(Market_is_closed() )

________break; // goes away. Resumes at the next tick (at market opening)

____RefreshRates(); // get fresh market information

____if(Ask==__ask) // apparently, no new info

_______continue;

........__ask = Ask; // new ask price, could also test for Bid changes

____go_trading(); // go open/close/modify

__}

}

I personally enjoy and have been using approach 1, but the eventual issue here is whether the server, for some reason, stops broadcasting ticks. There are many hypothesis for this to happen, such as in high market volatility causing overload, server’s workload in processing orders, network traffic jam, ....


In the approach 2, there is always the warranty that the EA is running and it obtains newer rates periodically in order to proceed with trading.


Conclusion: approach 1 seems the one used in every EA I’ve seen. It is the one I've used in assessing EAs. But it seems to depend on the server “benevolence” to receive ticks. Approach 2, on the other hand, seems more reliable, as it is always running and playing the game.

I haven't deeply studied this subject yet. So, I would really appreciate some wise opinions on this.

Thanks for the help. :-)

Joao

 

hi,

fwiw...

are u not over worrying the data receipt issue?

the system was designed so that experts, like any procedural lang's functions, gets called, does its functionality and exits/returns to caller.

the expert/start() is at end of day, just a function generally speaking, functions do not do while(1), if did then why is it a function?

i think call to refreshRates is not, in essence allowing your expert direct comms with server.

if there is data, the client gets it, if not it will not get it regardless of your expert making the refreshRates call.

they are not separated. the expert is not a program that can act on it's own - it makes calls into the Client Terminal system - not outside of it

iow, if server "stops broadcasting ticks" - the client ie, Terminal will in no way be able to give your expert data it does not have.

Data Ticks will be lost IF the expert is still running - the docs state this all over place.

eg, if 10 ticks make up a bar then say expert is not in start(). on Client receiving tick.1 the expert start() is called and is up to expert to 'grab' [or not] this tick.1

if expert decides to not exit start() and another 5 ticks are incomming to Client then expert cannot 'get them back' - all builtin calls only return the last incomming data tick. Assumes say u look at Close[0] all time in start() - u only ever see tick.1

ok... maybe this of interest

Best to U

Here is simple test done demonstrate how:

1. expert that never exits never sees new data ticks = 17348_while(true)

.

2. expert that exits always sees new data ticks = 17348_exitASAP

.

a chunk of experts tab on terminal follows:

2008.11.20 18:50:32 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:32
2008.11.20 18:50:32 17348_exitASAP EURJPY,M30: 119.705, 2008.11.20 18:50:32
2008.11.20 18:50:31 17348_exitASAP EURJPY,M30: 119.715, 2008.11.20 18:50:31
2008.11.20 18:50:30 17348_exitASAP EURJPY,M30: 119.725, 2008.11.20 18:50:30
2008.11.20 18:50:29 17348_exitASAP EURJPY,M30: 119.735, 2008.11.20 18:50:29
2008.11.20 18:50:28 17348_exitASAP EURJPY,M30: 119.745, 2008.11.20 18:50:28
2008.11.20 18:50:28 17348_exitASAP EURJPY,M30: 119.755, 2008.11.20 18:50:28
2008.11.20 18:50:27 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:27
2008.11.20 18:50:27 17348_exitASAP EURJPY,M30: 119.765, 2008.11.20 18:50:27
2008.11.20 18:50:26 17348_exitASAP EURJPY,M30: 119.775, 2008.11.20 18:50:26
2008.11.20 18:50:25 17348_exitASAP EURJPY,M30: 119.795, 2008.11.20 18:50:25
2008.11.20 18:50:22 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:22
2008.11.20 18:50:20 17348_exitASAP EURJPY,M30: 119.775, 2008.11.20 18:50:20
2008.11.20 18:50:18 17348_exitASAP EURJPY,M30: 119.765, 2008.11.20 18:50:18
2008.11.20 18:50:17 17348_exitASAP EURJPY,M30: 119.755, 2008.11.20 18:50:17
2008.11.20 18:50:17 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:17
2008.11.20 18:50:16 17348_exitASAP EURJPY,M30: 119.765, 2008.11.20 18:50:16
2008.11.20 18:50:14 17348_exitASAP EURJPY,M30: 119.775, 2008.11.20 18:50:14
2008.11.20 18:50:12 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:12
2008.11.20 18:50:07 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:07
2008.11.20 18:50:06 17348_exitASAP EURJPY,M30: 119.775, 2008.11.20 18:50:06
2008.11.20 18:50:04 17348_exitASAP EURJPY,M30: 119.775, 2008.11.20 18:50:04
2008.11.20 18:50:01 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:50:01
2008.11.20 18:50:00 17348_exitASAP EURJPY,M30: 119.765, 2008.11.20 18:50:00
2008.11.20 18:50:00 17348_exitASAP EURJPY,M30: 119.775, 2008.11.20 18:50:00
2008.11.20 18:50:00 17348_exitASAP EURJPY,M30: 119.795, 2008.11.20 18:50:00
2008.11.20 18:49:59 17348_exitASAP EURJPY,M30: 119.825, 2008.11.20 18:49:59
2008.11.20 18:49:57 17348_exitASAP EURJPY,M30: 119.835, 2008.11.20 18:49:57
2008.11.20 18:49:57 17348_exitASAP EURJPY,M30: 119.855, 2008.11.20 18:49:57
2008.11.20 18:49:57 17348_exitASAP EURJPY,M30: 119.865, 2008.11.20 18:49:57
2008.11.20 18:49:56 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:49:56
2008.11.20 18:49:56 17348_exitASAP EURJPY,M30: 119.855, 2008.11.20 18:49:56
2008.11.20 18:49:54 17348_exitASAP EURJPY,M30: 119.835, 2008.11.20 18:49:54
2008.11.20 18:49:53 17348_exitASAP EURJPY,M30: 119.855, 2008.11.20 18:49:53
2008.11.20 18:49:51 17348_exitASAP EURJPY,M30: 119.835, 2008.11.20 18:49:51
2008.11.20 18:49:51 17348_while(true) EURJPY,M30: 119.835, 2008.11.20 18:49:51
2008.11.20 18:49:49 17348_while(true) EURJPY,M30: initialized
2008.11.20 18:49:47 17348_while(true) EURJPY,M30: loaded successfully
2008.11.20 18:49:39 17348_exitASAP EURJPY,M30: initialized
2008.11.20 18:49:38 17348_exitASAP EURJPY,M30: loaded successfully
2008.11.20 18:49:07 Compiling '17348_while(true)'
2008.11.20 18:49:07 Compiling '17348_exitASAP'

and the two sources:

//17348_while(true).mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
while(true) {
Print(Close[0],", ",TimeToStr(TimeLocal(),7));
Sleep(5000);
}
return(0);
}

//17348_exitASAP.mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
Print(Close[0],", ",TimeToStr(TimeLocal(),7));
return(0);
}

 

forgot refreshrates call in while(true), and below code i put experts tab chunk o/p

//17348_while(true).mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
while(true) {
Print(Close[0],", ",TimeToStr(TimeLocal(),7));
Sleep(5000);
RefreshRates();
}
return(0);
}


//17348_exitASAP.mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
Print(Close[0],", ",TimeToStr(TimeLocal(),7));
return(0);
}

in faster market see much more of 'exit' expert prints in between the 5sec print of 'while(true)' expert and be even more discrepancy

2008.11.20 19:01:40 17348_while(true) EURJPY,M30: 119.895, 2008.11.20 19:01:40
2008.11.20 19:01:35 17348_while(true) EURJPY,M30: 119.885, 2008.11.20 19:01:35 not see 119.875

2008.11.20 19:01:31 17348_exitASAP EURJPY,M30: 119.885, 2008.11.20 19:01:31
2008.11.20 19:01:31 17348_exitASAP EURJPY,M30: 119.875, 2008.11.20 19:01:31 price changes,
2008.11.20 19:01:31 17348_exitASAP EURJPY,M30: 119.885, 2008.11.20 19:01:31
2008.11.20 19:01:30 17348_while(true) EURJPY,M30: 119.905, 2008.11.20 19:01:30
2008.11.20 19:01:25 17348_exitASAP EURJPY,M30: 119.905, 2008.11.20 19:01:25
2008.11.20 19:01:25 17348_while(true) EURJPY,M30: 119.915, 2008.11.20 19:01:25
2008.11.20 19:01:22 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:22
2008.11.20 19:01:20 17348_while(true) EURJPY,M30: 119.935, 2008.11.20 19:01:20
2008.11.20 19:01:16 17348_exitASAP EURJPY,M30: 119.935, 2008.11.20 19:01:16
2008.11.20 19:01:15 17348_while(true) EURJPY,M30: 119.945, 2008.11.20 19:01:15 not see changes, only get ...45 that IF exit EA ran at 01:15, would see exactly same. iow, 01:14->01:15 stays at ...45
2008.11.20 19:01:14 17348_exitASAP EURJPY,M30: 119.945, 2008.11.20 19:01:14 |
2008.11.20 19:01:14 17348_exitASAP EURJPY,M30: 119.925, 2008.11.20 19:01:14 |---price changes much, 3 changes will not be seen by while(true)
2008.11.20 19:01:12 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:12 |
2008.11.20 19:01:11 17348_exitASAP EURJPY,M30: 119.955, 2008.11.20 19:01:11 |

2008.11.20 19:01:10 17348_while(true) EURJPY,M30: 119.915, 2008.11.20 19:01:10
2008.11.20 19:01:08 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:08
2008.11.20 19:01:06 17348_exitASAP EURJPY,M30: 119.905, 2008.11.20 19:01:06
2008.11.20 19:01:05 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:05
2008.11.20 19:01:05 17348_while(true) EURJPY,M30: 119.915, 2008.11.20 19:01:05
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: initialized
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: loaded successfully
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: uninit reason 2
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: deinitialized
2008.11.20 19:00:50 Compiling '17348_while(true)'

 
Hello
It is very actual topic.
Approach 1 is only method for backtest and optimization purposes.
Approach 2 is more suitable for maximum terminal control.
Advantages of Approach 2 demonstrates Automation sample for the MetaTrader 4 Client Terminal.
As for ticks, Approach 1 may lose new ticks anyway
.
Best regards
Ais

 

//17348_while(true).mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
while(true) {
//Print(Close[0],", ",TimeToStr(TimeLocal(),7));
Print("modeBid/",MarketInfo(Symbol(),MODE_BID),", modeAsk/",MarketInfo(Symbol(),MODE_ASK),", ",TimeToStr(TimeLocal(),7));
Sleep(5000);
RefreshRates();
}
return(0);
}


//17348_exitASAP.mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
//Print(Close[0],", ",TimeToStr(TimeLocal(),7));
Print("Close[0]/",Close[0],", Bid/",Bid,", Ask/",Ask,", ",TimeToStr(TimeLocal(),7));
return(0);
}

2008.11.20 19:54:23 17348_while(true) EURJPY,M30: modeBid/118.775, modeAsk/118.805, 2008.11.20 19:54:23
2008.11.20 19:54:18 17348_while(true) EURJPY,M30: modeBid/118.775, modeAsk/118.805, 2008.11.20 19:54:18
2008.11.20 19:54:13 17348_exitASAP EURJPY,M30: Close[0]/118.775, Bid/118.775, Ask/118.805, 2008.11.20 19:54:13
2008.11.20 19:54:13 17348_while(true) EURJPY,M30: modeBid/118.805, modeAsk/118.835, 2008.11.20 19:54:13
2008.11.20 19:54:12 17348_exitASAP EURJPY,M30: Close[0]/118.805, Bid/118.805, Ask/118.835, 2008.11.20 19:54:12
2008.11.20 19:54:12 17348_exitASAP EURJPY,M30: Close[0]/118.825, Bid/118.825, Ask/118.855, 2008.11.20 19:54:12
2008.11.20 19:54:11 17348_exitASAP EURJPY,M30: Close[0]/118.835, Bid/118.835, Ask/118.865, 2008.11.20 19:54:11
2008.11.20 19:54:11 17348_exitASAP EURJPY,M30: Close[0]/118.855, Bid/118.855, Ask/118.885, 2008.11.20 19:54:11
2008.11.20 19:54:10 17348_exitASAP EURJPY,M30: Close[0]/118.865, Bid/118.865, Ask/118.895, 2008.11.20 19:54:10
2008.11.20 19:54:10 17348_exitASAP EURJPY,M30: Close[0]/118.875, Bid/118.875, Ask/118.905, 2008.11.20 19:54:10
2008.11.20 19:54:08 17348_while(true) EURJPY,M30: modeBid/118.885, modeAsk/118.915, 2008.11.20 19:54:08
2008.11.20 19:54:05 17348_exitASAP EURJPY,M30: Close[0]/118.885, Bid/118.885, Ask/118.915, 2008.11.20 19:54:05
2008.11.20 19:54:04 17348_exitASAP EURJPY,M30: Close[0]/118.895, Bid/118.895, Ask/118.925, 2008.11.20 19:54:04
2008.11.20 19:54:03 17348_while(true) EURJPY,M30: modeBid/118.905, modeAsk/118.935, 2008.11.20 19:54:03
2008.11.20 19:54:03 17348_exitASAP EURJPY,M30: Close[0]/118.905, Bid/118.905, Ask/118.935, 2008.11.20 19:54:03
2008.11.20 19:54:02 17348_exitASAP EURJPY,M30: Close[0]/118.915, Bid/118.915, Ask/118.945, 2008.11.20 19:54:02
2008.11.20 19:53:59 17348_exitASAP EURJPY,M30: Close[0]/118.905, Bid/118.905, Ask/118.935, 2008.11.20 19:53:59
2008.11.20 19:53:58 17348_while(true) EURJPY,M30: modeBid/118.915, modeAsk/118.945, 2008.11.20 19:53:58
2008.11.20 19:53:57 17348_exitASAP EURJPY,M30: Close[0]/118.915, Bid/118.915, Ask/118.945, 2008.11.20 19:53:57
2008.11.20 19:53:56 17348_exitASAP EURJPY,M30: Close[0]/118.895, Bid/118.895, Ask/118.925, 2008.11.20 19:53:56
2008.11.20 19:53:55 17348_exitASAP EURJPY,M30: Close[0]/118.885, Bid/118.885, Ask/118.915, 2008.11.20 19:53:55
2008.11.20 19:53:53 17348_exitASAP EURJPY,M30: Close[0]/118.895, Bid/118.895, Ask/118.925, 2008.11.20 19:53:53
2008.11.20 19:53:53 17348_while(true) EURJPY,M30: modeBid/118.885, modeAsk/118.915, 2008.11.20 19:53:53
2008.11.20 19:53:53 17348_exitASAP EURJPY,M30: Close[0]/118.885, Bid/118.885, Ask/118.915, 2008.11.20 19:53:53
2008.11.20 19:53:49 17348_exitASAP EURJPY,M30: Close[0]/118.885, Bid/118.885, Ask/118.915, 2008.11.20 19:53:49
2008.11.20 19:53:48 17348_exitASAP EURJPY,M30: Close[0]/118.895, Bid/118.895, Ask/118.925, 2008.11.20 19:53:48
2008.11.20 19:53:48 17348_while(true) EURJPY,M30: modeBid/118.895, modeAsk/118.925, 2008.11.20 19:53:48
2008.11.20 19:53:45 17348_while(true) EURJPY,M30: initialized
2008.11.20 19:53:43 17348_while(true) EURJPY,M30: loaded successfully
2008.11.20 19:53:36 Compiling '17348_while(true)'

 

Hello, i am new to mql4 programming... so here is the structure of the code that i am using


double order;
int type;

int init()
  {
// some indicators here....
   
   return(0);
  }

int start()
  {
  init();
  
  if(order == 0)
  {
      if(any condition)
      {
         Print("Open SHORT");
         order = OrderSend(Symbol(), OP_SELL, vol, Bid, 3, Ask, 0, "", NULL, 0, Red);
         type = 1;
      }

      if(any other opposite condition)
      {
         Print("Open LONG");
         order = OrderSend(Symbol(), OP_BUY, vol, Ask, 3, Bid, 0, "", NULL, 0, Blue);
         type = 2;
      }
  }
  
  if(order != 0)
  {
      init();
      if(type == 1)        // CLOSE SHORT
      {
         if( something )
         {
            OrderClose(order, vol, Ask, 3, Red);
            order = 0;
            type = 0;
         }
      }
      if(type == 2)        // CLOSE LONG
      {
         if( opposide something )
         {
            OrderClose(order, vol, Bid, 3, Blue);
            order = 0;
            type = 0;
         }
      }
  }  
   return(0);
  }


is that structure good or is bad? there is no magic code... how to add ?


and btw if an indicator is not initialized as that should be, what is the error value? 0 ?

 

fwiw - u would be wise to read MQL4 book will answer your questions and you will see why your structure should be altered...

the book really does answer most questions - so many not take this important first step and all times they post they could easily answer own questions by just reading...

i even make this mistake and if revisit the book and articles published on this site, many questions are answered.

if still unanswered, it is very profitable to learn yourself by reading source code files and doing own tests.

 
fbj:

forgot refreshrates call in while(true), and below code i put experts tab chunk o/p

//17348_while(true).mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
while(true) {
Print(Close[0],", ",TimeToStr(TimeLocal(),7));
Sleep(5000);
RefreshRates();
}
return(0);
}


//17348_exitASAP.mq4
int init()
{
return(0);
}
int deinit()
{
return(0);
}
int start()
{
Print(Close[0],", ",TimeToStr(TimeLocal(),7));
return(0);
}

in faster market see much more of 'exit' expert prints in between the 5sec print of 'while(true)' expert and be even more discrepancy

2008.11.20 19:01:40 17348_while(true) EURJPY,M30: 119.895, 2008.11.20 19:01:40
2008.11.20 19:01:35 17348_while(true) EURJPY,M30: 119.885, 2008.11.20 19:01:35 not see 119.875

2008.11.20 19:01:31 17348_exitASAP EURJPY,M30: 119.885, 2008.11.20 19:01:31
2008.11.20 19:01:31 17348_exitASAP EURJPY,M30: 119.875, 2008.11.20 19:01:31 price changes,
2008.11.20 19:01:31 17348_exitASAP EURJPY,M30: 119.885, 2008.11.20 19:01:31
2008.11.20 19:01:30 17348_while(true) EURJPY,M30: 119.905, 2008.11.20 19:01:30
2008.11.20 19:01:25 17348_exitASAP EURJPY,M30: 119.905, 2008.11.20 19:01:25
2008.11.20 19:01:25 17348_while(true) EURJPY,M30: 119.915, 2008.11.20 19:01:25
2008.11.20 19:01:22 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:22
2008.11.20 19:01:20 17348_while(true) EURJPY,M30: 119.935, 2008.11.20 19:01:20
2008.11.20 19:01:16 17348_exitASAP EURJPY,M30: 119.935, 2008.11.20 19:01:16
2008.11.20 19:01:15 17348_while(true) EURJPY,M30: 119.945, 2008.11.20 19:01:15 not see changes, only get ...45 that IF exit EA ran at 01:15, would see exactly same. iow, 01:14->01:15 stays at ...45
2008.11.20 19:01:14 17348_exitASAP EURJPY,M30: 119.945, 2008.11.20 19:01:14 |
2008.11.20 19:01:14 17348_exitASAP EURJPY,M30: 119.925, 2008.11.20 19:01:14 |---price changes much, 3 changes will not be seen by while(true)
2008.11.20 19:01:12 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:12 |
2008.11.20 19:01:11 17348_exitASAP EURJPY,M30: 119.955, 2008.11.20 19:01:11 |

2008.11.20 19:01:10 17348_while(true) EURJPY,M30: 119.915, 2008.11.20 19:01:10
2008.11.20 19:01:08 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:08
2008.11.20 19:01:06 17348_exitASAP EURJPY,M30: 119.905, 2008.11.20 19:01:06
2008.11.20 19:01:05 17348_exitASAP EURJPY,M30: 119.915, 2008.11.20 19:01:05
2008.11.20 19:01:05 17348_while(true) EURJPY,M30: 119.915, 2008.11.20 19:01:05
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: initialized
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: loaded successfully
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: uninit reason 2
2008.11.20 19:00:50 17348_while(true) EURJPY,M30: deinitialized
2008.11.20 19:00:50 Compiling '17348_while(true)'


This pattern confirms that first approach is more reactive to the market, because it runs with every tick arriving to the terminal.

Second approach only runs every 5 seconds.

Firts approach stops running if ticks are not delivered.

=====> However, the important point is not on the marginal time (seconds), as illustrated in the above log.

Imagine that your EA, due to something, didn't receive a tick that last 15 minutes, for a very active instrument, and you lose a great move. Would second approach, on these situations, work better because it is in control and is explicitly requiring fresh information?

Therefore, the main point is whether there are undesirable conditions/situations that cause an EA stop receiving ticks even for a very active instrument, in which you might lose a great opportunity for profit or close a position.

If these situations do exist, would second approach better overcome them?


Thanks for the feedback.

 
Hello
Tick counter code sample:
int start ()                                                                                        // 01
{                                                                                                   // 02
static int ali.TicksReported.0 ; ali.TicksReported.0 = iVolume ( Symbol () , PERIOD_M1 , 0 )      ; // 03
static int ali.TicksReported.1 ; ali.TicksReported.1 = iVolume ( Symbol () , PERIOD_M1 , 1 )      ; // 04
                                                                                                    // 05
static int ali.OpenTime.0      ; ali.OpenTime.0      = iTime   ( Symbol () , PERIOD_M1 , 0 )      ; // 06
static int ali.OpenTime.1      ; ali.OpenTime.1      = iTime   ( Symbol () , PERIOD_M1 , 1 )      ; // 07
                                                                                                    // 08
static int ali.FrameLength     ; ali.FrameLength     = TimeCurrent ()      - ali.OpenTime.0       ; // 09
                                                                                                    // 10
static int ali.TicksCounted.0                                                                     ; // 11
static int ali.TicksCounted.1                                                                     ; // 12
                                                                                                    // 13
static int ali.LastOpenTime                                                                       ; // 14
                                                                                                    // 15
static int ali.Flag ; if       ( ali.Flag != True ) { ali.Flag = True                             ; // 16
  ali.TicksCounted.0           = ali.TicksReported.0                                              ; // 17
  ali.LastOpenTime             = ali.OpenTime.0                                                   ; // 18
  Alert ( "Start" )            ; return                                                         ; } // 19
                                                                                                    // 20
if   ( ali.LastOpenTime       == ali.OpenTime.0 )                                                   // 21
       ali.TicksCounted.0     ++                                                                  ; // 22
else { ali.TicksCounted.1      = ali.TicksCounted.0                                               ; // 23
       ali.TicksCounted.0      = 1                                                                ; // 24
       ali.LastOpenTime        = ali.OpenTime.0                                                   ; // 25
       Alert ( "Frame 0 "      ,                                                                    // 26
               "is closed: "   , TimeToStr ( ali.OpenTime.0 , TIME_MINUTES | TIME_SECONDS ) , " " , // 27
               "Count: "       , ali.TicksCounted.1                                         , " " , // 28
               "Report: "      , ali.TicksReported.1                                          ) ; } // 29
                                                                                                    // 30
Alert        ( Symbol ()       , " M1: "   , "Frame 0: "                                          , // 31
               "Open: "        , TimeToStr ( ali.OpenTime.0 , TIME_MINUTES | TIME_SECONDS ) , " " , // 32
               "Seconds: "     , ali.FrameLength                                            , " " , // 33
               "Count: "       , ali.TicksCounted.0                                         , " " , // 34
               "Report: "      , ali.TicksReported.0                                        , " " , // 35
                                 " //  "   , "Frame 1: "                                          , // 36
               "Open: "        , TimeToStr ( ali.OpenTime.1 , TIME_MINUTES | TIME_SECONDS ) , " " , // 37
               "Count: "       , ali.TicksCounted.1                                         , " " , // 38
               "Report: "      , ali.TicksReported.1                                            ) ; // 39
}                                                                                                   // 40 
This sample illustrates that some ticks may be lost even without any computing load.
As for advantages of Approach 2, A System: Code Sample 3 demonstrates server inspection in real time.
Best regards
Ais

 

has anyone considered deinit() in all this?

how can it get called if in basically a forever loop in start()?

wat if expert chopped dead in water?

wat about 1 or more open trades... left open and unmanaged?

btw, i asked [reasonably] in depth about the 2.5secs and deinit() and Sleep() etc. but [as usual] my posts never get answered, so i throw above into cook pot ;)

.

"AAA.AAA.9"

how strange that MT compilers lexical analyzer not reject such <identifier> composition... docs clearly state:

"

Identifiers are used as names of variables, functions, and data types. The length of an identifier cannot exceed 31 character.

Symbols you can use: numbers from 0 to 9, Latin capital and small letters a to z, A to Z (recognized as different symbols), the symbol of underlining (_). The first symbol cannot be a number. The identifier must not coincide with any reserved word.

"

i not see full stop/period in this paragraph. ok, works? but they free to fix and turn off tap any time = no one can complain cuz docs clearly state allowed characters = maybe much work for Ais...

.

is this drop off of MetaQuotes Corp?

a test shows that this invalid identifier is allowed and compiles and runs - why so???

:)

 
Hello
As for "deinit ()" function, A System: Code Sample 3 stops very correctly.
It checks "IsStopped ()" condition and within "ac.RunTimePeriod = 1000" ms releases cycle.
1000 ms seems like a much less than 2.5 seconds.
It is OK to place "deinit ()" in A System: Code Sample 3 and check it
.
Best regards
Ais