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 -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
something like this could do it. Basically you'd have to store the bar number at the time you send the order and as long as the current bar number is smaller than the saved one + 15 you are good to take the trade.
This is the pseudo code for doing that:
input your code and add a exit using number of bars like 6 bars from entry but multiple entries exit on the same bar of first signal rather 6 bars from entry
say c<ema and bar 0 1 2 3 all are c<ema and are valid entries
signal 0 should exit at 6 bars and signal 1 should exit at bar 7 signal 2 should exit at bar 8 but instead all the signals exit together at bar 6
how to ensure all signal each exit 6 bars from entry?
your original request was for a order being active for X bars. You reply now suggest you are actually looking for something different i.e. a trade being closed after X bars. Maybe you can elaborate on what you are exactly looking for and I (or other) would be able to much better help you.
The signal would be from the condition which is valid for next 15 bars
Say for c<ema15 is the signal and bar 0 there is a signal the exit would be on next x bars
if on bar 1 c is still < ema15 this would be a second signal and would exit on the next x bars counting from the second signal bar NOT on the first signal entry bar
The second third signals would buy despite first signal has not exited
johni,
this is an example taken from the Tradestation forum, showing how you can tie an exit to a specific entry.
This will be something you need to do as well in your code.
Did try the from entry code but the problem is if the signal condition is valid for more than the number of buy code you specified they may not be accounted for
Is there a loop code to ensure all signals are accounted for?
You need to adapt the code to the number of entries you are taking of course. This was just an example to get you going.
As orders can't be within a loop you will probably have to hard code all entries and exits.
Buying at Highest(H,1) and Highest(H,2) are different signals thus require from entry to tag them
However the problem is having similar signals with exiting filled order
Say buy whn stoch<30 and today there is a buy signal (stoch<30) and tomorrow stoch is still <30 so there is another buy similar signal with existing signal filled (yesterday)
Want to have each buy (similar signal) exit 5 bars from the entry
So today buy signal would tmr exit 5 bars from today but tmr buy signal would exit 5 bars from tmr not today