How to make an EA only trade once per bar, ie, once per hour max??

 
Hello:

Could you please take a look at the following EA, and let me know what modifications I need to make to have it only enter a trade once per bar? (I run this on the 1H or 4H Time frame)

When back tested, the code enters more than one trade per bar, but I know that is not a good test, as the tester is only "guesstimating" what happened within the bar.

Also, I need to make sure it enters a trade when the signals trigger, even if there is slippage or slow trading context or slow response from broker (as per usual).

Any help will be greatly appreciated.

Regards

Not Here.
 
nothere:
Hello:

Could you please take a look at the following EA, and let me know what modifications I need to make to have it only enter a trade once per bar? (I run this on the 1H or 4H Time frame)

Regards
Not Here.


datetime Time0 = 0;
 
void start()
{
  if (Time0 != Time[0])
  {
    OrderSend(...
    Time[0] = Time[0];
  }
}
MQL How-To Guide
 
RickD:
datetime Time0 = 0;
 
void start()
{
  if (Time0 != Time[0])
  {
    OrderSend(...
    Time[0] = Time[0];
  }
}
MQL How-To Guide
Shouldn't this be:
Time0 = Time[0]
As written, Time0 gets never updated and the test will always be true.
 
Hello:

Thanks for you replies RICKD and ZUIJLEN, I appreciate them!!

I am going to try both methods to see the result.

it is important to make sure the trade happens only once per hour, because the backtester is UNRELIABLE otherwise.

Best regards to both!!!

NOT HERE.......
 
nothere:


it is important to make sure the trade happens only once per hour, because the backtester is UNRELIABLE otherwise.

You need to read Strategy Tester: Modes of Modeling during Testing and My First "Grail"
 
Hello Rosh:

Thanks for the pointers, but I have already read these docs.

Having read the documets you point out, and many others related to this and many other backtesters, has led me to have the opinion I expressed above, which remains unchanged.

I use backtesters only to have a general idea about the way the algorithm behaves under test conditions, not to equate backtesting performance to forward or out of sample performance.

Thanks!!!
 
Resolved, thanks!
 
Can anybody tell me will the above program advised will function with MT4, or is that only for MT5?
 
Jenna Lyn:
Can anybody tell me will the above program advised will function with MT4, or is that only for MT5?

What above program?

This is in the MT4 section.

Reason: