My EA is a volatility EA which uses ATR in several ways. I enter on a 5min chart based on a custom indicator I had coded. I use a fraction of the ATR value of the daily chart to place stops. I've been testing different methods (tight stops with higher lot sizes vs larger stops with smaller lot sizes) to look at a strategy that gets both gains from smaller moves and also stays with a longer trend.
Anyway, what I would like to do is the following:
- When indicator gives signal, have the EA compare MarketInfo minimum stop with the stop proposed by the EA.
- If EA stop is less than minimum allowed by broker then either change stop (and recalculate lot size to keep risk the same) and then place order at min stop level, OR if I get the Error 130 then close trade immediately.
At the moment a trade is placed every now and then where a stop can't be placed (Error 130) and my trailing stop function then sees no SL and places one but the trailing SL is larger than the initial SL and I end up with the occasional large loss. After seeing this error crop up every now and again there's no way I can let an EA go live without being able to handle errors as I would like.
The other thing that comes to mind is "How are errors handled?" I'd like to have routines in place to work around errors like 130 but perhaps if other error types come up then the trade would be closed immediately.
I'm happy with the logic of my blocks but I just need the MarketInfo data. If you don't provide access to this can I create a custom block myself using MQL code?
Thank you for your prompt response by the way.
Kind regards,
Steve.