gahankaripradyumna

find bulish patterns

In this script:

We continue to calculate the bullish engulfing condition for monthly candlesticks (engulfingConditionM) as before.

We then create two variables (engulfingConditionY and lastYear) to calculate the yearly engulfing condition.

We use an if statement to check if the year has changed compared to the previous bar. If it has, we update the engulfingConditionY variable; otherwise, we keep the previous year's value.

Finally, we plot the monthly and yearly signals on the chart.

This code allows you to work with monthly data and calculate yearly signals based on the monthly data available in TradingView. Please note that this is an approximation and not true yearly resolution data, but it's a common workaround used in TradingView Pine Script.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?