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 have been using an automated strategy for tradestation for a couple of weeks now. it does ok, but i would like to improve the exits i have as of now. i will post these questions in the tradestation community forums too, but i could get some pointers here as there are accomplished easylanguage programmers in bmt too, and the ts forum is down as of now.
i would like my strategy to go with the trend; buy a stock when the price is above a simple moving average and other indicators are pointing upwards, and sell it when it is below the sma.
my code for long positions looks like this now:
if Price >= AverageFC( Price, Length ) and -another condition- then begin
Buy PSize Shares next bar at market ;
Avg = AverageFC( Price, Length ) ;
if Price < Avg then
Sell all shares next bar at market ;
end;
entries work ok, but i don't like how the exits behave right now. let's say it buys, it is all well, but it should drop the position as soon as the price is below the sma, yet i have seen my strategy hold onto positions that have crossed the sma down and only close them when it is opening a reverse position. it only closes a long position when it opens a short position and viceversa. i would like the strategy to hold positions only when they are outside the sma. how would code look like to achieve this?
and a second question, if i wanted a strategy to exit as soon as two consecutive bars have gone against my position, how would code look like to achieve this?
i tried:
If ( Price [2] > Price [1] and Price [1] > Price ) then
Sell all shares next bar at market ;
but seemingly it won't work.
any guidance will be appreciated, thanks, regards.
Can you help answer these questions from other members on NexusFi?