Is it possible to re-initialise re-initialize EA automatically?

 

How to ensure the EA will automatically initialize automatically when a new tick made?


I searched the forums for this and did a Google search also, no results that were relevant, no doubt a hardcore user or gatekeeper on here will find a thread that is related though, one that does not help me! No doubt. This thread is probably against my better self and wisdom. I know I can receive better help elsewhere, if historical stats of other threads on here are anything to go by.


Willing to have another solution offered to me other than on new tick, problem is when having my EA trade on an offline chart and server loses Internet connection or MT4 is restarted I have to do this manually or it won't trade. Even when I do this is still fails to trade or close out old orders when it opens new ones. It should always close out old trades before or upon opening new ones. TP and SL levels are not set to improve execution speeds of EA and set later after trade is open.


Frustrating to have this problem with such a promising mechanised strategy. It normally performs 80%-82% win rate but when this problem arises it causes troubles. Sorry, but I cannot share the code at this time.


I need to overcome this so I can further engineer the strategy to maximise profit and minimise risk or rather take advantage of risk. It uses high risk method and this is why it works so well, based on a crude approach to high probability win rate of historical statistics.


Is this a fault of the EA design or can it be improved by making the EA auto-initialise.


Also losing some open trades that runaway and should close before new orders are made.


Any tips or snippets of code in this area or a working example is useful. Anyone wondering if I am asking for something for free is wrong, I typically always give more than I ever ask of others, not in online forums but other means, like charity and direct help in other non FX related areas. My main driving force that got me into trading was to help as many people as possible (without greed or profiteering unlike many so called philanthropists that do) and in the future I intend to start some charities in area s that are well needed. Just FYI, as I do not have this in my profile or posted anywhere else. Since I do not expect anything in return, I do not mind if no one responds here. If you have some smart-ass comment, you can expect to be ignored for showing your ignorance.


I am not a pro or anything so please excuse me.


Thank you.

 
Sorry, I don't understand what your problem is . . . start() is run on each new tick . . unless start() takes a long time and is still running when the next tick arrives, in that case it runs again once it has completed and a new tick arrives. So I don't understand what you mean by . . . . " How to ensure the EA will automatically initialize automatically when a new tick made? "
 
FXIA:

How to ensure the EA will automatically initialize automatically when a new tick made?

...

Willing to have another solution offered to me other than on new tick, problem is when having my EA trade on an offline chart and server loses Internet connection or MT4 is restarted I have to do this manually or it won't trade. Even when I do this is still fails to trade or close out old orders when it opens new ones. It should always close out old trades before or upon opening new ones. TP and SL levels are not set to improve execution speeds of EA and set later after trade is open.

...

I'm lost too :(

Mmmm, how about

1. Instead writing codes in init(), writing them in user defined function and call it from init() or start().

2. Create tight loop in start() and call a start() from init() that way no need for expert button to turn on. Don't forget some sleep(). Check volume[0] for a new tick.

3. Delete all MT profile(s) then create a new one and name it default which include offline chart, that way when MT restarted the offline chart will be shown too.

Just some guessing suggestion :(

init()
  {
  //my_init_func();
  start();         // call start from init()
  return(0);
  }

start()
  {
  my_init_func();
  
  while (true)
    {
    if (iVolume(Symbol(), PERIOD_M1, 0) != Last_Volume)  // only when there's a new tick
       {
       Last_Volume = iVolume(Symbol(), PERIOD_M1, 0);
       
       // codes goes here
       
       }
    Sleep (50);
    }
  }

 
onewithzachy: 2. Create tight loop in start() and call a start() from init()
You can not call start from init. Init MUST return within 2 seconds. https://www.mql5.com/en/forum/128803/page2#373533
 
WHRoeder:
You can not call start from init. Init MUST return within 2 seconds. https://www.mql5.com/en/forum/128803/page2#373533

He he he ...

I have no problem calling start() from init() on EA

 
Thank you guys. I've been dealing with some other things so please excuse me for not writng back sooner than now. The init looks fine so I am thinking it is to do with the MM and how it handles that. I have an option to set a TP and SL but ordinarily the trade strategy doesn't need a SL as it has price to trigger an exit for this so it makes calculation of MM more dependent if a win/loss occurs. Had problems with it before so now going to test something else out. Currently checks for losses but not for open trades and think that might prevent the runaway open trades from being left open when a new order should close them out.