I'm working on an EA and I'm implementing a trailing stop loss, since neither MT4 nor my broker supports that feature out of the box, I have to implement it programmatically by modifying a SL closer all the time. That leads to a lot of Modify calls per order.
When I'm trying to use a tester to test my EU, 99% of all messages I get are modify messages which pollutes my log and my Results tab. I was wondering if there was a way (via configuration or programmatically) to supress those kinds of messages. they don't add any value (in my example) and just makes it increasingly harder to look for information that is actually useful for me.
You could modify your code so that the trailing stop moves in steps.
ie i pip instead of 1 point or maybe even 5 pips in larger time-frames.
That would reduce the number in the log.
Another way would be to write a stealth trailing stop.
ie instead of actually modifying the trade, save the trailing stop value (in an array, if more than 1 trade open at a time).
Then check if price hits it and close the trade.
Yeah, I'm already doing that, in fact I step 10 pips everytime, but nevertheless, because I'm working with Day trends and oscillations, and my tp/sl spreads are relatively wide, I get a lot of modify even with a 10pip step. Also, at any given time, I might have more than 1 order (in fact I have somewhere around 10 - 20 orders) so multiply that number by numbers of modifies I get in my logs...
I could pump it up a larger pip step, but that will actually start crippling my algorithm, and I can't afford to do that just to improve logging.
This is what I'm talking about...
No it's not, having to maintain the data structure for each of those orders in memory. And then if EA gets deinit/init - all those get wiped out (I know you're going to suggest to serialize to file and re read...)
Anyway, it seems that there is no easy answer... other than code my way around it...
You can connect the magic number to the stops and targets.
So if the EA is restated it reads the magic number of the open trades and knows immediately how far away the stops and targets should be from the actual prices?
As you specifically stated that you are running the EA in strategy tester, deinit/init will not be an issue.
In real time, the history tab does not record every order modify
You could save the stops in a Global Variable of the client terminal, maybe using the ticket number as the GV name.
To add comments, please log in or register