EA keeps trading multiple times per bar

 

I am having issue with the attached EA trading multiple times per bar. I only want it to place max one trade per bar. I have tried to edit the code but it still seems not to work.

Please could someone have a look and tell me where I have gone wrong?


Many thanks.

 
  if (ThisBarTrade != Bars) {

You do not assign a new value to ThisBarTrade, so the above condition will always be true

 
GumRai:

You do not assign a new value to ThisBarTrade, so the above condition will always be true

Like this

if (ThisBarTrade != Bars) {
ThisBarTrade = Bars;
 

Thank you to everyone for your help. I was able to use your advise to fix the problem.

Many thanks!

 
Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
 
WHRoeder:
Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum
You are wrong(again).
 
eevviill:
You are wrong(again).
YOU are wrong, can't you stop flooding the forum with bad advice and code ?
 
eevviill: You are wrong(again).

Explain why.

Daily chart has Thursday and Friday. Bars = 2.

New history comes in. Chart now has Tuesday, Wednesday, Thursday, Friday. Bars now equals 4.

Bars changed but it is still Friday. No new daily bar.

 
WHRoeder:

Explain why.

Daily chart has Thursday and Friday. Bars = 2.

New history comes in. Chart now has Tuesday, Wednesday, Thursday, Friday. Bars now equals 4.

Bars changed but it is still Friday. No new daily bar.

Waste of time. This guy NEVER listen, he must have some brain bugs.

 
zirkoner:

Waste of time. This guy NEVER listen, he must have some brain bugs.

Oh thank you. Better to have bug in brain than to do not have brains.
 
WHRoeder:

Explain why.

Daily chart has Thursday and Friday. Bars = 2.

New history comes in. Chart now has Tuesday, Wednesday, Thursday, Friday. Bars now equals 4.

Bars changed but it is still Friday. No new daily bar.

Why no new day? Tuesday && Wednesday:)))))))

 

Do you agree with me that if history updates we need to recalulate data(especially in indicators)?

I understand about what you talking mounth ago. But i am talking about another thing. 

Reason: