Code needed to stop opening position

 

Hi,

I have a trend following EA. It seems to work fine except for one problem. And that is, with given conditions it opens position at the end of the trend as well as it does along the way and gets trapped in a drawdown. I was wondering if there is any way that can prevent it from opening a position at the end of a trend.

Thank you all. 

 
Rmsh Raj:

Hi,

I have a trend following EA. It seems to work fine except for one problem. And that is, with given conditions it opens position at the end of the trend as well as it does along the way and gets trapped in a drawdown. I was wondering if there is any way that can prevent it from opening a position at the end of a trend.

Thank you all. 

Of course, say him the trend is ending and it should not take position in such case.
 

It is mot difficult to prevent the EA from opening trades.

The difficult part is writing code that recognises that the trend is ending.

If you have any logic to determine that a trend will end before it actually reverses, please let me know.

 
Keith Watford:

It is mot difficult to prevent the EA from opening trades.

The difficult part is writing code that recognises that the trend is ending.

If you have any logic to determine that a trend will end before it actually reverses, please let me know.

Thanks. That's the trickiest part I guess, I should have asked instead if there is any way for an EA to find that the trend is stalling. Maybe we can analyze like three or four or five previous bars to see how price is behaving, if price closes below the first historic bar then the uptrend has ended (or is going to retrace at least for now) and if it closes higher the trend might be in continuation, something like that.

Could there be any idea that can be extracted from Trailing Stop. I am zero in coding. EAs I test are build with help of this program, you might as well familiar with, FXPro Quant. It is super easy and anyone can do kind of interface where all one need is an idea of what one is doing and know how to connect things around. It's trailing stop parameters are Magic Index : relate positions, I guess, Wait for profit : Yes/No , Trailing Stop Points : I've set it 20, Min Adjustment Points : I've set it 10. Now, I was wondering if it works this way ; suppose I opened long, now if the price moves by 20 points in my direction, the take profit is upped by 10 points in that direction, let's call this point A, Now again if the price moves another 20 points from A then the take profit is upped another 10 points and it goes on as long as price is going in that direction without retracing to the take profit level. At some point the price is going to retrace and hit the take profit level and book the profit, exiting the trade. Now, when the profit is taken and trade is exited, let's assume that in indication of opening Long for the main position triggering code is still there (and it will execute another Long position), but I don't want to open the Long position at this point (of course the price might have retraced as a correction and might resume in Long direction after some time, but I'd like to wait, I guess we can do this with code.). If possible, I'd love to backtest this idea and see the result.

Does whatever I said above make sense ?

Thank you.