Simple automated trading example for alpaca.markets written in C#.
Buys at the low of day at 10:00 AM EST if the first hourly candle closes red. Day orders are used so they cancel at the market close. The strategy essentially resets everyday if there is no fill.
Sells when the position is up half the hourly 20 period Average True Range (ATR).
Holds the bag until profitable.
You should have a live alpaca.markets brokerage account for real time data from Polygon. If you do not, you will need to modify the code to retrieve data from their free API that utilizes IEX. Using the free data means there will be missing bars on certain stocks and possibly wrong OHLC values. This will affect entries for the strategy.
Upon first start a
settings.json file will be created. This file allows you to set your Alpaca API keys and the symbols you want it to trade.
Do not use this to trade with a live account without rigorous testing and do expect to lose all your money if you use the implemented strategy. I take no responsibility for how you use this code.