Open and close
-
On strategie tester this works perfect on a 4hr timeframe. The condition says to open trades at the opening of a new bar. But I have no clue why it is also closing trades on that event. The condition is a crossover and nowhere in these trades that condition changed at the time of closing. Neither was a target reached or a stop hit. (The same thing happens on 2 different broker platforms. Including one ECN broker)
Up to now I am only testing with very small lots on live accounts.
See pictures attached.
-
You have connected "Close each trade" right after "Buy now" and "Sell now".
When "Buy now" or "Sell now" creates it's trade, it continues to the orange output and what can be found there... "Close each trade". So, the result is that a newly created trade is immediately closed.If you want to close trades after another condition, place "Close each trade" on a different group of blocks with that condition.
Also, instead of "Counter..." blocks, you can use blocks from "Manage trades/orders count" category.
Don't test on live real account. First test on Strategy Tester (Visual mode is a good option), then on demo account... and if everything is fine for sure - on real account.
-
More detailed picture of the buy and sell. The filters are on an in my opinion it can only close any buy or sell trade when the condition changed.
Since the condition which is set at X< D or X > D never changed it should add a new trade instead of close an open trade.In other words it should work live as well. Condition is simple and stops are a good distance away.
......
Details.png
tradesrunning.png -
I don't understand what is the problem - trades are closed when no need to, or trades are not closed when need to?
I will suggest to use "No trades...." blocks instead of these counters.
-
There is no problem that is my problem
On the third picture from the top which was created in the strategy tester it does exactly what it needs to do. It closes at the right stops and it also closes any sell trades when a new buy comes on. It trails trades 100% right as seen on buy trade 3. So everything is as I want according to the blocks you provided. There are no closes on new bars. Its all perfect.But when going live it closes trades on new bars which it doesn't do in the tester. ( The tester is 100 right and so the Robot is 100% accurate)
So nothing complicated at all.
Only when going live its not doing what it should do.
But I take your advice and do the following:
1: I start over again with the same stuff and run it on tester and demo account.
2: If that doesn't work I look over it again and again and let you know the outcome.
3: When that doesn't work I try to find a way around it as you suggested.But this EA is perfect because have tested on many pairs and commodities and it makes good profits over a year of Data on all.
So why change something that is good
Again only live its acting weird. (Below another perfect picture of a perfect EA on the strategy tester.)
......
perfect.png -
If something works on backtest and not love, then the first thing to see is if there are error messages.
But I think it's something else. You are saying this:__
But when going live it closes trades on new bars which it doesn't do in the tester.[/quote:1d19hf59]This probably means that your trades are closing right when a new bar opens, without any other condition. Can you check if there is another EA currently working on another chart, some EA that you forgot working?
-
Now that sound a bit like logic. I have 4 EA's open on 4 different pairs with 4 different magic nr's.
But just in case I will reastart the computer and EA's.
Indeed the only thing I can think of. Must be somewhere in that direction.
Will get back when I found the solution or...

BTW I keep on testing live with 1 cent trades before going over to the real stuff.
-
Restarted everything and checked all. Have one EA running on a GBPUSD. Only that chart is open so it will be easy to find any errors when they happen. Next trade should start in 15 min and to see if it works will take at least 4hr or more.
-
By the way you can always test live on smaller timeframe where things happens much quickly, for example on M1. There is no reason to wait 4 hours if you can wait 1 minute (or 5-15 minutes if 1 minute candles are too small)

-
Well I be damned. Its working on 1 min gold live. (The GBP 4hr is in as it should) So in short like I said in the chat room, for whatever reason it looks like a computer keeps some old stuff from before in the back of its mind. Anyway its telling me that whenever you start an EA and have been playing before it is essential that you restart eveything clean before doing anything at all.
Almost certain now its not the program that remembers stuff from the past but the computer itself.
Thanks for that last and final tip that gave us the solution

-
Perfection as I said all along

......
perf.png -
Just to let you know:
That 4hr GBPUSD trade with the EA is also working perfect now.
Another indication something must have been somewhere in the computers mind.
Lesson learned is: When it's acting weird. RESTART ALL

-
Don't "panic" so much :)) It's normal to forget some EA working on another chart. This happens to me often, even when I use the Tester most of the time. Actually backtesting helps for this to happen, because there is new chart created on every backtest, and eventually you have tons of charts and you don't remember where EAs are and if there are any somewhere
So... closing all charts should be enough.