Download MetaTrader 5

EA keeps trading multiple times per bar

To add comments, please log in or register
Josh Calow
39
Josh Calow  

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.

Keith Watford
Moderator
10566
Keith Watford  
  if (ThisBarTrade != Bars) {

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

Vasyl Nosal
19431
Vasyl Nosal  
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;
Josh Calow
39
Josh Calow  

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

Many thanks!

whroeder1
16336
whroeder1  
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
Vasyl Nosal
19431
Vasyl Nosal  
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).
Zirkon
121
Zirkon  
eevviill:
You are wrong(again).
YOU are wrong, can't you stop flooding the forum with bad advice and code ?
whroeder1
16336
whroeder1  
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.

Zirkon
121
Zirkon  
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.

Vasyl Nosal
19431
Vasyl Nosal  
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.
Vasyl Nosal
19431
Vasyl Nosal  
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. 

12
To add comments, please log in or register