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)
I’m building an ES Tick-bar strategy in TradeStation Easy Language.
I have coded a specific bar that will trigger an entry several bars later. The number of bars later will vary.
Question: How can I reference the trigger bar (actually; the High or Low of the Trigger bar) as a value for my exit stop, after my entry has been filled?
Attached example depicts a long trade. Any suggestions?
Can you help answer these questions from other members on NexusFi?
you wrote "I have coded a specific bar that will trigger an entry several bars later. ". Just save the values you need from that trigger bar into variables at the moment you detect the trigger bar.
In other words you will have conditions for what makes your trigger bar and every time these are met, you can also store the values you need to use later.
By the way you can show your appreciation for a post on futures.io by clicking the "Thanks" button next to it.
I don’t know how to Store the values for later. Please elaborate.
My Trigger Code is:
//Long Entry Trigger
If Condition2[1] and Condition3 and (Condition7 or condition8) and not Condition10 then begin Buy ( "LE" ) next bar at market;
MP = 1;
End;
I need to add something to my code that will mark the Low of my trigger bar (not my entry bar) as my stop; if and when, my order is triggered”.
you are welcome. It appears your code snippet is for the bar that actually triggers the entry. Storing the values of that bar would be too late as you want the trigger bar values (at least this is my impression from what you wrote).
Not knowing what your conditions for the trigger bar are and what values you actually want to store, I am afraid but I can't be of much help besides providing you with an pseudo code example that you'd have to adapt to fit your needs.
This would store the high and low of each trigger bar, but it would also overwrite the values with each new trigger bar. This might be something you need to deal with - for example by not allowing the code to overwrite (you'd need to code that) the values while you are waiting to go long and then storing these values in a second variables at the moment you send the order. Please keep in mind that these are just ideas and depending on what exactly you need the code to do will not accomplish that, but it's a good start that you can adapt to your needs.
Sorry for the confusion. Yes, my code below is for 'next bar' entry, but my question could apply to a second bar or third bar (I probably would not go past three bars) beyond the trigger bar where I would want to use a pre-established value (based on my Trigger Bar) as an exit.
So; to clarify:
For a Long Position, I want to store the Low of my Trigger Bar. I plan to use the "TriggerLow" value to:
a) Automatically set an exit order for a Long Position, based on the low of a previous bar
b) Automatically exit the Long position on the first tick (of the first instance) that the “TriggerLow” value is broken to the down side.
and
c) Allow the process to start fresh when I again receive my next ‘TriggerBar’.
In my feeble attempt to to code this function, I have created a variable called “triggerLow(0);” and inserted it in my Long Entry code as follows:
If Condition XX then begin Buy ( "LE" ) next bar at market;
MP = 1;
TriggerLow=Low;
End;
And, I have set-up the Long Exit code as follows:
If MarketPosition > 0 and L< (TriggerLow=Low) then begin Sell next bar at Market.
MP=0;
End;
Comments or suggestions?? I can use all the help I can get
My apologies for not getting back to you in a timely manner.
I have been working on this exit code for over a week, and I decided to take a break and study-up on Variables before importing your code.
In you last post you stated: "This {your code} would store the high and low of each trigger bar, but it would also overwrite the values with each new trigger bar. " That is exactly what I'm looking for.
I'll set-it-up tomorrow and report back on the results.
Thanks again for your prompt response, and my apologies for not getting right on it.
my post above was meant in regards to your post #6 in this thread as you asked for comments and suggestions in that.
One suggestion I have is that you probably would get more help from other users if you'd post actually working code. By that I don't mean reveal your exact logic, but you could for example create demonstration code that shows the same behavior that you are having trouble with or want corrected. This will not only make things a lot clearer as someone trying to help you can see exactly what you see it will also make it easier for others to help you.
Good News !!!!! I merged your code with mine, and it worked much better than anything I have tried thus far, but there are issues (details below) that I hope you can help me with.
//Long Entry
If Condition2[1] and Condition3 and (Condition7 or condition8) and not Condition10 then begin Plot1(Low, "LE",red);
MP = 1;
End;
//Long Exit on Break of Trigger Bar bottom
If MP=1 and L < triggerBarLow then begin Plot2 (Low, "LX", Cyan);
MP = 0;
End;
Description of Issues:
For the most part, the function is operating properly. The function is:
1) capturing a specific value
2) Implementing the value (as an Exit) only if MP=+1
3) Re-setting the value after each trigger bar, if MP=0
My Issues Are:
1) My exits are being made on <Entry Bar Low, not < Trigger bar Low.
2) There are instances where the exit criteria are met, but no exit was made.
3) In at least one case, an exit was made on a subsequent trigger Bar Low.
4) Late Exit.
5) Exits in places they should not be.
I have attached screen-prints of each issue (numbered per above Issue-Numbers).
• Trigger Bars on attached screen-prints are Magenta.
• Long Entries taken (on the basis of trigger bars) are marked by Red Dots.
• Long Exits taken (on the basis of trigger bars) are marked by Cyan Dots.
I'm assuming I did not input your code properly. Please review and provide comments, or suggestions.
As always, I want to thank you in advance for you time and expertise.
Respectfully,