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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
Thanks! that's exactly what I was looking for.
Size:
Color: