In order to trade on the beginning of an open bar only, add the following code:
static datetime timeprev; // at top of program
if(timeprev==Time[0]) { //at beginnign of start()
return(0); //only execute on new bar
} else if (timeprev==0) {
timeprev=Time[0]; //prevents execution when loading EA onto chart
} else {
timeprev=Time[0];
H4Processing();
SendMail();
}
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
Is there any FAQ for EA/Strategy tester?
Please provide the link if any.
I am trying to write/test an EA where the logic will be tested at close of each 4 hour bar.
Is there any facility like this on EA?
Does EA checks for each tick only?
Or it can be modified to check some parameters only after a close of 4 hour bar. For example I am trying to buy/sell based on a EMA cross of 5/21 but I want to do that only at the closing of a 4 hour bar and not for the every tick as being done in EA/Indicator.
Thanks in advance for your time/replies.
Kent