Update - was able to make it work by utilizing the count and start positions fir iLowest and iHighest with the start index as today.
Thank you for the help!

Update - was able to make it work by utilizing the count and start positions fir iLowest and iHighest with the start index as today.
Thank you for the help!

And this will automatically connect to the buffers that the indicator has declared. If so, that's VERY helpful!
Thank you
I added the additional buffers as shown above, and then in an ugly comment printed them out and it all appears to be working!
@sktsec Found out it was the build version. Build 4040 works well, the latest demo build 4057 has a terribly slow strategy tester.
I ended up finding the issue - something I've never seen before. I have 4 once per bar blocks that execute and they were out of order and this is somehow causing my trades 'once per bar' to execute twice? I re-ordered them and this solved the issue. Still a VERY strange issue considering I disable the flags after a trade is place, at the top of my 'once per bar' I have a number of positions check to make sure it's less than 1, and 'on trade' I disable the flags also.

Sorry - thought I fixed the issue with the above renumbering, but it was actually this block... I didn't realize it goes down the logic path two times in this scenario.
I turned off the 2nd condition and I no longer get double trades. Dummy.
I use the strategy tester in MT5 for all my data - it gets the data from the broker where I also run the EAs. Data is very important - I've found optimizing from broker to broker is VERY different and should be avoided. If you test and tune on a specific brokers data, you should also run the EA there.
I can't edit your project, but you need to create a condition block that checks to see if the high/low today, is higher/lower than yesterday's high/low. If that is true, then you set a flag (call it violation_today) to true. In your logic for actually placing the trade, you need to make sure the flag (violation_today) is true, if so, you can proceed.
@martymoon120 MT5 has a strategy tester where you can optimize parameters. Sounds like exactly what you need to do. Seems like you just need to optimize on how many pips to place the SL and where to start a trailing stop. I see 4 variables there that need to be optimized on... RR, trailing stop start, size, step. You can easily do this in MT5
This is a dumb question, but are you running the EA on the same broker that you tested on? There can be a significant difference between brokers, but the EA should NOT read the charts differently in any case.
You could write a simple EA that takes a trade every bar with a 0.01 lot size. See if that executes, if so, you know that EA's are working correctly on MT5. If not, then you might have found the issue. Outside of that, we'd have to see your EA to know what the issue might be.
Roar posted about this, you need to loop through positions and use close, vs the general 'Close Positions' block. Pink, not blue.
Consider the edge cases on what the last 5 candles might look like in extreme situations. You may be better off using an ATR value with a modifier coefficient, something like 1.5X the ATR for the last 5 or 10 candles.
I ended up finding the issue - something I've never seen before. I have 4 once per bar blocks that execute and they were out of order and this is somehow causing my trades 'once per bar' to execute twice? I re-ordered them and this solved the issue. Still a VERY strange issue considering I disable the flags after a trade is place, at the top of my 'once per bar' I have a number of positions check to make sure it's less than 1, and 'on trade' I disable the flags also.

Sorry - thought I fixed the issue with the above renumbering, but it was actually this block... I didn't realize it goes down the logic path two times in this scenario.
I turned off the 2nd condition and I no longer get double trades. Dummy.
Hello,
I have a strange bug in my EA that is somehow creating two positions despite having flags and checks in place so that only one trade should happen.
My EA checks for certain conditions and flags in order to enter a trade. If all conditions are met, it places a trade, resets the flags and moves on. For some reason, it is now creating two positions when the order is sent and I have no idea why. At the top of my logic, I check for position count, it needs to be less than 1 for this group (yes, double checked all the groups are correct) and if there are no positions it goes down and if all logic is passed, it opens a trade (single buy/sell now) and then resets the flags. No idea why, but this is somehow opening 2 trades.
This EA has previously been working and this is suddenly happening... Any chance there has been some alterations to the back end code?
The condition before the two sells is for testing, it's a boolean check to see if I want to use lots or % for the trade. There is NO way that is being executed at the same time.


This seems like an interesting approach. Would be nice to see a diagram of the initial order, when the first TS starts and the size, and then when the 2nd kicks in. I struggle with a similar problem - my EA has a nice TS but often it leaves a lot of profit on the table. I use my size as a portion of my initial SL size, so it's dynamic. With only 1 TS it's difficult to capture all (or the majority) of profit.
The best way to handle this is to use flags on candle close. Pending orders are a challenge to deal with, because you have to have checks to make sure that you don't keep opening pending orders and have 100 orders ready to get tagged in. So what I would do, is when you have identified a CHoCH, you identify the entry price and SL level. Once per bar, you should check to see if the last candle high/low was above/below the entry price and then do a market order to enter.
@Archer I'd love to take a look at this, if possible but the transfer is no longer valid. Do you mind sharing the file again?
You're going to want to loop through all open trades, check if price is X pips away from open, if so, once-per-trade, modify stops, set to open price of the trade. That's your BE. For the trailing stop, it's a simple block and you have the offset start when price is x pips away from open. Although, I will tell you, this type of EA is VERY unlikely to be profitable. Think about spread, commissions, etc..