NexusFi: Find Your Edge


Home Menu

 





EasyLanguage - coding trailing stop below confirmed lows


Discussion in EasyLanguage Programming

Updated
    1. trending_up 1,691 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 18 posts
    2. attach_file 2 attachments




 
Search this Thread

EasyLanguage - coding trailing stop below confirmed lows

  #1 (permalink)
timfel
London, UK
 
Posts: 19 since Mar 2023
Thanks Given: 5
Thanks Received: 1

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.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Futures True Range Report
The Elite Circle
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
Battlestations: Show us your trading desks!
18 thanks
  #2 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29

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) ?

Reply With Quote
  #3 (permalink)
timfel
London, UK
 
Posts: 19 since Mar 2023
Thanks Given: 5
Thanks Received: 1



abev View Post
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.

Reply With Quote
  #4 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29

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.

Reply With Quote
  #5 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29

....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.

Reply With Quote
  #6 (permalink)
timfel
London, UK
 
Posts: 19 since Mar 2023
Thanks Given: 5
Thanks Received: 1

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.

Reply With Quote
  #7 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29

I'm remembering the ZigZag Indicator in EL. That's the best I can do.

Reply With Quote
  #8 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29

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.

Reply With Quote
Thanked by:
  #9 (permalink)
 bfulks 
Boston MA
 
Experience: Advanced
Platform: TradeStation
Trading: Stocks and options
Posts: 24 since Aug 2022
Thanks Given: 2
Thanks Received: 4

I am not sure I totally understand your description but this should be pretty close.

Bob Fulks

Attached Files
Elite Membership required to download: TrailingStop.pdf
Reply With Quote
Thanked by:
  #10 (permalink)
abev
seattle washington
 
Posts: 75 since Feb 2019
Thanks Given: 11
Thanks Received: 29


Seems to me that would do the trick.

Reply With Quote




Last Updated on June 13, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts