Buy Stocks between a certain price
Author: CemCalim
Creation Date: 7/31/2014 10:11 AM
profile picture

CemCalim

#1
Hi all,

I want that my strategy only takes Stocks between 10$ and 100$. Buy no Stock under 10 $ or over 100 $. How can I enter this in the code?



profile picture

Cone

#2
Just add this extra condition at the top of your entry logic. If a stock's price is too low or too high, this statement will simply skip the rest of the logic and continue to the next bar.

CODE:
Please log in to see this code.


There's no problem doing this as a filter for live trading, however, I would caution you that using such a condition for backtesting is "peeking" since it doesn't take into account splits that may occur in the future. In this case, there's another technique to use to make this test against the "unadjusted" series.
profile picture

Eugene

#3
CODE:
Please log in to see this code.
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).