Download MetaTrader 5

Fuzzy Logic - Open Price Only

To add comments, please log in or register
baldonius
16
baldonius  

I have been testing the expert advisor Fuzzy Logic in the Strategy Tester and I have noticed that it is much more profitable when using the Open Prices Only (OPO) setting. I think this is because of the EA's take profit setting.

Obviously in live trading it uses every single tick, so I was wondering where to start customising the code to emulate the OPO behaviour in live trading?

 Is it simply a case of changing the open order and close order functions so they activate only when a new bar opens? I want to emulate OPO as much as possible.

Here is the .mq4 file for Fuzzy Logic.

Fuzzy Logic by Guest
  • physicle.com
View Fuzzy Logic, created by Guest.
arcull
150
arcull  
baldonius:

I have been testing the expert advisor Fuzzy Logic in the Strategy Tester and I have noticed that it is much more profitable when using the Open Prices Only (OPO) setting. I think this is because of the EA's take profit setting.

Obviously in live trading it uses every single tick, so I was wondering where to start customising the code to emulate the OPO behaviour in live trading?

 Is it simply a case of changing the open order and close order functions so they activate only when a new bar opens? I want to emulate OPO as much as possible.

Here is the .mq4 file for Fuzzy Logic.

This shouldn't be hard to do. In the start function you could always check if minute changed and if it did, let the rest of the code run, otherwise exit. I forgot how it goes in MQL4 but in MQL5 you would write something like this:
currmin=TimeToString(TimeCurrent(),TIME_MINUTES);
TimeToStruct(TimeCurrent(),CurrTimeStrct);
if(CurrTimeStrct.min!=PrevTimeStrct.min) {
  // normal flow         
  PrevTimeStrct = CurrTimeStrct
} else {
  return(false);
}
However I think you are on the wrong track by doing so. OPO setting mean you completely ignore the ticks inside the time frame, which obviously in your case would trigger stop losses or what ever the logic which closes orders. Not sure, give it a try and if it works stick to it :)
baldonius
16
baldonius  
arcull:
This shouldn't be hard to do. In the start function you could always check if minute changed and if it did, let the rest of the code run, otherwise exit. I forgot how it goes in MQL4 but in MQL5 you would write something like this:However I think you are on the wrong track by doing so. OPO setting mean you completely ignore the ticks inside the time frame, which obviously in your case would trigger stop losses or what ever the logic which closes orders. Not sure, give it a try and if it works stick to it :)

I found a solution.

First, declare `datetime LastRunTime;`

Then wrap the inside of the start() function like so:

void start() { 

if(LastRunTime != iTime(NULL,0,0))

{

 ... normal start() function stuff

}

LastRunTime = iTime(NULL,0,0);

To add comments, please log in or register