Hello,

Is it possible to code a strategy like this?  

Each day, I want an algorithm to use 25% of my account to long or short TQQQ.  If the first 5-minute candle of the day is green, the algorithm opens a long position.  If the first 5-minute candle of the day is red, the algorithm opens a short position.  In other words, if during the first 5 minutes the market moved up, we take a bullish position starting from the second candle’s opening price. Conversely, if the first 5-minute candle was negative, we take a bearish position at the open of the second 5-minute candle.  Please do not open a position when the first 5-minute candle is a doji (open price = close price).

I want the algorithm to close the position if a stop loss of 5% of the 14-day Average True Range is hit.  If that stop loss is not it during the day, I want the algorithm to close the position a few seconds before the market closes for the day.  Thanks!