I am incredibly new to programming, and I am having trouble finding open-source info out there on how to program in entry/ exit logic and position sizing. Any help would be much appreciated as I do not know how to implement previous blog posts on the topic.
I have already implemented a pipeline that filters and screens my stock universe down to the securities in which I am targeting. So the following would have to apply the logic daily to the daily pipeline returns.
Entry Logic
- Short MA crosses above (and closes above) Long MA
- Orders are placed after hours and placed at the market at the beginning of the next trading day
- Include slippage and fees
Exit Logic
- Close below the Short MA
- Short MA crosses (and closes) below Long MA
- Trailing Stop is Long MA
- Trailing Stop is triggered (This is the only intraday order in the strategy. Limit order updated daily depending on program output)
- Orders are placed after hours (except trailing stop orders) and placed at the market at the beginning of next trading day
- Include slippage and fees
Position Sizing
- The risk for each trade is 1% of the portfolio balance
- On the day entry logic is triggered: Long MA = Trailing Stop. Closing price - Trailing Stop = Risk per share on trade. 1% of portfolio / Risk
per share on trade = Number of shares to be purchased
- Initial buy order must not be higher than 5% of the entire portfolio
Thank you