if Period( )!=15; return(0);
this will kill your ea, if the period is not 15min,
place this code right after the start()
c0d3 wrote >>
this will kill your ea, if the period is not 15min,
place this code right after the start()
the OP should place your code in the init(), not the start(), no need to check chart time period on every tick and the init() will be re-ran if someone were to change the chart after attaching the EA to it.
And please correct me if I'm wrong, but placing
if Period( )!=15; return(0);
in init() won't stop the EA. Init returns 0 anyway. is it not better
bool trade=false; if (Period()=={desired timeframe})trade=true;
placed in init() and then start start() with if (trade==true) { //do stuff}
V
Viffer:
Yeah, sounds about right. Variable 'trade' should be on a global scope for this to work... Alternatively u can have the EA stuck in a loop in init() if the condition is not met.
And please correct me if I'm wrong [...]
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
hi,
i am writing an EA which should only work on a 15 minute chart. i would like to check the period in the init() function and if it is not correct (ie. 15 minutes) then the EA should produce an error message and refuse to start. at present i am circumventing this by making a check on the period each time that start() is called, but this does not really solve the problem since the EA still runs for the wrong period (although it does nothing). is it possible to just make the EA stop dead if the initial conditions are not met?
thanks a lot,
andrew.