Ok great thanks for that RaptorUK...that makes sense. I will give that a go.
JoBlo:
datetime BarTime1 = 0;
if (BarTime1 < Time[0])
BarTime1 = Time[0];
TechnicalAnalysis()
- BarTime1 must be static or global.
- use != not < (in case server resets their clocks)
static datetime Time0; bool newBar = Time0 != Time[0]; Time0 = Time[0]; TechnicalAnalysis();
WHRoeder:
- BarTime1 must be static or global.
- use != not < (in case server resets their clocks)
Thank you WHRoeder for the help...that has sorted the problem.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all,
I have been working on a simple support/resistance EA. The EA places a buy or sell order when the price
meets the support/resistance line and the preceeding bar meets certain criteria. The problem I have is that
if I close out the position (for whatever reason), the EA creates another buy/sell because the conditions are
still being met (eg, if I am on a 15 min chart and close the order 6 mins after the new bar started, the conditions
are still being met for the next 9 mins and the EA will therefore open another order).
I have tried to get the EA to only carry out the Technical Analysis when the next bar opens, but this doesnt seeem to
stop it from opening another order once one is close. To accomplish this, I have been using the following code :
datetime BarTime1 = 0;
if (BarTime1 < Time[0])
BarTime1 = Time[0];
TechnicalAnalysis()
Is this the correct method of instructing the EA to carry out the TechnicalAnalysis only on every new bar ?
Is the there any other way of stopping the EA opening a new order once one is closed (as described above) ?
Thanks for taking the time to help a noob ! ;)