Download MetaTrader 5

EA keeps trading multiple times per bar

To add comments, please log in or register
Read the Forum and improve your rating!
Josh Calow
39
Josh Calow 2016.03.16 20:01 

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
9596
Keith Watford 2016.03.16 20:25  
  if (ThisBarTrade != Bars) {

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

Vasyl Nosal
18533
Vasyl Nosal 2016.03.16 22:48  
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 2016.03.17 12:17  

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

Many thanks!

whroeder1
14460
whroeder1 2016.03.17 14:59  
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
18533
Vasyl Nosal 2016.03.17 15:21  
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
122
Zirkon 2016.03.18 14:22  
eevviill:
You are wrong(again).
YOU are wrong, can't you stop flooding the forum with bad advice and code ?
whroeder1
14460
whroeder1 2016.03.18 14:40  
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
122
Zirkon 2016.03.18 14:43  
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
18533
Vasyl Nosal 2016.03.18 22:43  
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
18533
Vasyl Nosal 2016.03.18 22:48  
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