Exit at Market after a Close below Stop price
Author: SimhaD04
Creation Date: 8/19/2012 12:09 PM
profile picture

SimhaD04

#1
I want the code to sell based on certain RSI conditions and also to have a stop sell if price moves below purchase price by a certain amount.

Here's the trading loop for this:

CODE:
Please log in to see this code.


The problem is that the program flags stocks for sale, which are not subject to either condition. E.g. take MSFT which closed at 30.90. The program bought the stock at 29.48. If you run it now, it says "sell" with the price 28.59. This is correct, since my stop is 3%, but the question is why is it telling it to me now, when the price is 30.90? In other words, how to fix this trading loop to make it flag only actionable sells?

Thanks.
profile picture

Cone

#2
It is an actionable sell. It's telling you that you have to enter an order to Sell xxx shares MSFT at a stop price of 28.59 tomorrow.
profile picture

SimhaD04

#3
how to change it, so that the sell comes up only when the stop sell condition is fulfilled by the closing price? In the example above, if MSFT were to drop <=28.59, then it would issue a sell. Thanks.
profile picture

Cone

#4
For a stop order, if MSFT drops below the stop's trigger price tomorrow, the trades tab and chart will show that you sold the position after you update the data on Monday night. This is how a "touch stop" works.

However, it sounds that you're looking to exit at market after a close below your stop price. In that case, code would look like this -
CODE:
Please log in to see this code.
profile picture

SimhaD04

#5
Thanks! that's exactly what I was looking for.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).