how to code to check if price has crossed its resistance. Manually, I used to draw trendline and resistance on tradingview and if closing price used to cross above this line, this was the breakout.
How do I achieve the same using Algo. is there anyway, i can draw trendline using code
@Anupam_Agarwal It’s a great question and something that I am working on as well. On a basic level for drawing lines i.e. trend lines(Up, Down) or support/resistance lines(Horizontal), you need to master Linear regression(ML) to plot points and then identify the line. For a Uptrend line, you need to plot the lows of candlesticks in a specific timeframe. Similarly, for a Downtrend line, its the highs of candlesticks. Things get complicated when you have a horizontal line because then the points plotted need to be fine-grained to show proper support or resistance. Ultimately its too much work and overtime it would improve but at the moment I feel that choosing stocks manually, plotting support and resistance boxes of 3% with a max distance between 2 resistances of 15-20% is better and quicker. Once we have the box, you can insert the prices in each box in your code so that whenever the price reaches that level, you can decide to buy or sell. These boxes need to be adjusted during corporate actions.