Ea trades during candle instead of the close

 

This is a good working HMA EA except for one thing, it it buys or sells during the candle as it changes which could do a short then the candle turns long and at the close your short with a long trend. I would like the buy or sell desicion to take place at the end of each candle not during.

Can some one help me with this problem.

Files:
 
int Start() {
  static datetime Time.newBar;
  bool newBar	= (Time[0] > Time.newBar); if (newBar) { // A new bar began.
	Time.newBar	= Time[0];			 // Reset static.
	//...
  }
  //...
 
WHRoeder wrote >>int Start() {
static datetime Time.newBar;
bool newBar = (Time[0] > Time.newBar); if (newBar) { // A new bar began.
Time.newBar = Time[0]; // Reset static.
//...
}
//...

Thanks WHR I'll test it and let you know.

 
traderdukeFX:

This is a good working HMA EA except for one thing, it it buys or sells during the candle as it changes which could do a short then the candle turns long and at the close your short with a long trend. I would like the buy or sell desicion to take place at the end of each candle not during.

Can some one help me with this problem.

What are the settings for this ea?, Timeframe, pair?


Thanks

 
Everett wrote >>

What are the settings for this ea?, Timeframe, pair?

Thanks

Still testing, I haven't had a chance to try the new candle calculation. I'll post later next week.

 
traderdukeFX wrote >>

Still testing, I haven't had a chance to try the new candle calculation. I'll post later next week.

WHR

That change didn't seem to change anything, could you check to see if I did correctly?? I new at MQL programs.

Thanks

Files:
 
traderdukeFX wrote >>

WHR

That change didn't seem to change anything, could you check to see if I did correctly?? I new at MQL programs.

Thanks

WHR

I found out from some other forum that the answer to the problem is

Volume[0]==1

See Below, it was added to the indicator;

if ( trend[1]<0 && trend[0]>0 && Volume[0]==1 && !UpTrendAlert)

Thanks for your effort

Case closed

 
traderdukeFX:

WHR

I found out from some other forum that the answer to the problem is

Volume[0]==1

WHRoeder's time-comparison method is probably better, depending on exactly what your trading rules are. It's possible for MT4 or an individual EA to miss a tick. The Volume[0]==1 comparison would cause a bar to be skipped if the first tick of the next bar was missed. Whereas WHRoeder's method acts on the first tick which is received in each bar, rather than expecting to see a tick specifically with Volume[0] = 1.

 
jjc wrote >>

WHRoeder's time-comparison method is probably better, depending on exactly what your trading rules are. It's possible for MT4 or an individual EA to miss a tick. The Volume[0]==1 comparison would cause a bar to be skipped if the first tick of the next bar was missed. Whereas WHRoeder's method acts on the first tick which is received in each bar, rather than expecting to see a tick specifically with Volume[0] = 1.

Your absolutly correct. I'm seeing missed signals and I wasn't sure why. I guess I'll retry placing WHR's idea some where else. I have it down near the bottom at this time. Could you tell me if there is a better spot?? Its the same file as above

Thank you for responding.

Files:
 
traderdukeFX wrote >>

Your absolutly correct. I'm seeing missed signals and I wasn't sure why. I guess I'll retry placing WHR's idea some where else. I have it down near the bottom at this time. Could you tell me if there is a better spot?? Its the same file as above

Thank you for responding.

Can anyone help me? I have a great EA written by and enhanced by several knowledgeable people but it has one flaw. It trades during a interval/candle. In a Long trend this can cause you to close a buy and then go short. Now you have a short position in along trend.

What can I key on or change to get this EA to not determine any changes until the end or close of a interval/candle? This would cause a change that would be reflected in the open of the next interval. I have tried the following that have failed in various ways:

Volume[0] ==1 ; Causes you to miss 2-3% of the signals.

int Start() {
  static datetime Time.newBar;
  bool newBar         = (Time[0] > Time.newBar); if (newBar) { // A new bar began.
         Time.newBar   = Time[0];                // Reset static.
         //...
  }

//...

Either I placed it wrong or it has no effect.

You can see the failure in the back test and more so in the live test.

I have attached the EA with the above inputs installed but not active in the EA. If you can place them or any other ideas with success let me know.

Please help me fix this problem and join me in its success.

Use the base EA attached with H4 GPBCHF 12-01-09 to 12-30-09 and you will be staring at the problem at 12-16 04:00 and 12-24 0:00. This was the best way to present the problem.

 
forget how to attach
Reason: