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 trying to code / find a modified version of a profit target.
the profit target automated strategy included in tradestation does fine, but it always closes the whole position.
i would like to be able to drop half my position at say, position +1.5, and keep the other half to be closed by the standard profit target, stop loss strategies.
i'm trying to code it, but can't even get tradestation to return the entry price, much less set the exit properly.
any help would be appreciated, thanks.
Can you help answer these questions from other members on NexusFi?
- Open two positions and each with half of the total shares/contracts
- send a limit exit order for the target for the first leg of your entry
- either send a limit exit order for the second target or use the build in Profit Target
You can get the entry price with the reserved word EntryPrice(Num).
Where Num is a numeric expression representing the number of positions ago (up to a maximum of ten).
thanks, i have been working on this development but haven't been able to make it work up to now.
right now the code looks like this, i only modified the structure for the entries/exits based on some information i found on some other internet pages:
if (long entry conditions met)... then begin
buy("hr") (PSize1) Shares next bar at open;
buy("lr") (PSize2) Shares next bar at open;
entr=c;
end;
sell("sl lr") next bar from entry("lr") (entr-sl) stop;
sell("sl hr") next bar from entry("hr") (entr-sl) stop;
sell("pt hr") next bar from entry("hr") (entr+pt2) limit;
sell("pt lr") next bar from entry("lr") (entr+pt1) limit;
setexitonclose;
so far only the first buy command is executed, whether i have the hr or lr command, only the one on top is filled. and, entryprice does not work, i am using close of last bar. if i change it to entr=entryprice; the strategy sells at the same spot it buys at.
did you allow multiple entries in one direction? If not Tradestation might simply block the second entry although your code is correct. By default this is not enabled.
Go to the strategy properties and check "Allow up to ... entry orders in the same direction"
I am not sure what you did with EntryPrice, but if you post the code I can take a look at it.
effectively, once i changed the properties for all strategies i can get more than one position at once.
the code above seems to be working, so it should help in case anyone is searching for something similar.
now, i haven't been able to get the true entry price with the reserved word entryprice, the best approximation is - c -, the previous bar's close. i have tried entryprice, entryprice(0) and entryprice(1) but to no avail.
in the end i was able to code exactly what i was looking for: a hard limit profit target that drops only a fraction of a position. i share the code in case it can be of help for someone:
more profit target points can be added or removed using the same logic.