Trailing stop
Forums › ProRealTime English forum › ProOrder support › Trailing stop
- This topic has 7 replies, 3 voices, and was last updated 7 years ago by
juanj.
-
-
09/07/2017 at 10:51 PM #45758
Hi, I have been working on a simple startegy, but I need a specific trailing stop loss. The trailing stop needs to always pick the highest lows during the past x days. Visually it would be like a stair moving higher as the price moves higher. This should also be the case when the price moves lower, then the stair moves downwards. I have read a few posts about this in the forum, but the code posted on these threads does not work. Could anybody please give me some help about this?
Thank you in advance!
09/08/2017 at 8:23 AM #45778Hi Gard
I understand what you are looking for but in reality placing a stop at or even just below a previous low is a very obvious place to get yourself stopped out. Markets tend to frequently pull back to these level (just at or below a previous low) to take out obvious stops and then continue onwards. You would most likely be far better off using something like the trailing stops in the below 2 threads (trust me on this);
https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
https://www.prorealcode.com/blog/learning/trailing-stop-max-favorable-excursion-mfe/
Regards,
09/08/2017 at 11:35 AM #45807Hi Juanj
Thank you for your reply. Yes I know, but when that trailing stop is working I can further manipulate it by multiplying it with a factor of, say 0.99, which will shift the “trailing stair” downwards. By doing so, I can find the multiplying factor that I am confortble with, and at the same time have a trailing stop that behaves the way I want to. I will also have a look at the threads you have linked.
Thank you again for your answer!
09/08/2017 at 2:47 PM #4581109/08/2017 at 5:07 PM #45814Hi Eric
Thank you for your reply. If you try to graph it, you can see that it moves just like the low of the daily movements, i.e., up and down just like any asset. What I aim to code, is a stop that only moves upwards when the asset moves up, and any corrections down, would not lower the stop. Just like an stair. This should happen when one is long that asset, and vica versa if one is short.09/08/2017 at 7:57 PM #45815@Gard, the code Eric provided should function as you describe.
But maybe just to flesh it out a bit;
where x = the number of bars to look back on (gets the highest low in that period)
where y = the number of points/pips to place the stop below that previous low
Note the below code will only be able to close the position at the next evaluation based on your timeframe (i.e. delayed by 1 timeframe unit)
123456789//Trailing StopPreviousLow = Highest[x](low)[1]If close <= PreviousLow - y ThenIf longonmarket ThenSell at marketElsIf shortonmarket ThenExitshort at marketEndIf09/08/2017 at 10:02 PM #4581909/09/2017 at 9:41 AM #45830 -
AuthorPosts
Find exclusive trading pro-tools on