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 set the data normalization mode to RAW.  

I want the algorithm to close the position if a stop loss of 5% of the 14-day Average True Range is hit.  I want the algorithm to log Average True Range and price values at each entry to help with debugging.  Something like the example debug pasted below if possible.  If the stop loss is not hit during the day, I want the algorithm to close the position a few seconds before the market closes for the day.  Thanks!

 


 

  1. self.debug(f"{self.time} Price: {price} ATR: {self._atr.current.value} StopDist: {stop_distance}")