Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Does anybody know how to code a trailing stop exit strategy in EasyLanguage, based on market structure, trailing the stop below the most recent low, where the low is only confirmed by taking out the most recent high? In other words it’s not necessarily the lowest price over the last few bars, it’s only valid as a confirmed low if the subsequent price move took out the high before it.
Can you help answer these questions from other members on NexusFi?
Certainly doable. Are you coding in .net or original version of EL? Regardless, your first issue is to define "most recent high". You and I can spot those highs without even thinking about it but to tell a computer how to identify the most recent high.....not so easy. Doable though. Have you taken a look at highest(function) ?
I don’t know about the dot net version of EL, I’m using TradeStation 10 and the EL that comes with that. The problem with finding the recent swing low, is that for me a low is only confirmed if the high before it is broken. It’s not a confirmed low for me until that happens, so it’s not as simple as the lowest low in the last few bars, because it could still be below the high, and as such, not a valid low yet.
You were smart to post here 'cause if anyone can help they would likely watch the posts here. Unfortunately (imho) you're going to have to code this yourself for the simple reason that you have a very personal definition of the low. You'll need to go through your thought process when you decide you've identified either the last high, or the current low and code it up. In other words, describe the event which clearly defines a high other than the highest high in the past x bars.
Once you have that, someone here will likely be able to help with questions on how to best code it.
....and it occurred to me that I've seen EL scripts that attempt somewhat successfully to mark the swing highs and lows on a chart. I'll see if I can find one of them later tonight and post it here.
Yes, I think you’re right, I’m going to have to figure it out myself!
I’m surprised nobody else does this, because my method of defining lows is really not very idiosyncratic. It’s very common amongst manual/discretionary traders. The low is only confirmed when the preceding high is broken - otherwise how do you know that the low is not just a part of the pullback, and there is more downward movement to come? It’s only when the high is taken out that you know yes, that really was the low.
Seems simple enough to code what you want. I don't think of it as a trailing stop but rather a series of stops where the new order cancels the previous order. lol -- yeah that's basically a trailing stop but most trading platforms and brokers will do all the canceling for you. Here I think you will have to cancel the previous order in the code. Regardless, let me see if I understand what you are attempting.
- a high is made -- call it H1
- a pull back takes place and a low is made -- call it L1. L1 will never be used nor mentioned in the code
- a new high is made that is higher than H1 -- call this new high H2
- a pull back takes place and a new low is made -- call this L2
- he L2 is confirmed to be a low because it broke below the price of H1
- we want a stop to be placed below L2 and all previous orders to be canceled.
Is that about right? I'll assume is it correct and ask how you define a high. Many I know define H2 by the extent of the pull back. I.e. if the pull back is 50% to 66% of the price difference from L1 to H2, then H2 is confirmed as the high. If that pull back also took out H1, you would have your confirmed low L2.
Now one must confirm H1 as being a high and to do that you would have to define an H0, and so on. The only way I can see to get around an infinite recursion into the past to define H2,1,0,etc. is to define the first high with a manual input to be used by the script.