CAParticipant
New
Hello,
I am trying to make, somehow, the following:
- My trading system requires to have an initial stop loss of 150 points.
- Then I have a target, let’s say, at 300 points.
- However, instead of establishing a target on the 300 points I would like just to create a new stop once the 300 points with a trailing stop of 50 points, that way I can still having benefits from the trend.
I have been trying several codes for this pourpose but I have not been able to code it!
Any ideas? Is it actually possible?
Hi,
>> Please update your country flag in your profile. Thank you 🙂 <<
Many times already this question has been answered 😉
You’ll find many trailing stop function on the website, in all sections (forums, library, blog).
You can start with the ones from the blog:
Complete trailing stop code function
Trailing stop with the Max Favorable Excursion (MFE)
CAParticipant
New
Hi Nicolas,
Thank you for your reply. Although you answer actually solve my question (I read the posts you refered me to) what I actually need to do is a bit diferente and I thought it would be similar to what I asked (trying to simplify the question) but after I read your posts it turned out that it actually does not solve it (sorry!).
Actually, what I need is related to ADX indicator. So for instance, I have a initial stop of, lets say, 150 points and an ADX level of 20. I would hold my positivo until ADX leve goes upto level of 40. There is were I need to move up the stop and start making a trailing stop of 20 points.
Is it possible to code this? Can I link an stoploss + trailing to ADX?
I would appreciate your answer!!
Regards,
Of course you can link the trailing stop activation to any other condition. Make a simple test with ADX to allow or not the trailing stop to operate:
if adx[14]>20 then
allowtrailing = 1
else
allowtrailing = 0
endif
if allowtrailing then
//put trailing stop function here
endif
CAParticipant
New
Thank you Nicolas!! It worked!!!