Tax planning is very complicated.
I have seen many tax planning in my 40 years career in taxation. I am a tax specialist myself What you suggest doesn't work.
Do you have $25,000 RRSP contribution room available?
Capital Gain will not increase your contribution room..
HBP can not be use for the purpose you indicated.
There are conditions for using the HBP.
One of them is you must buy a qualify principal residence within one year.
https://www.fidelity.ca/en/insights/articles/how-home-buyers-plan-work/#:~:text=Basic%20eligibility&text=You%20must%20be%20a%20resident,after%20buying%20or%20building%20it.
If you take money out of RRSP from HBP, you have to pay back within 15 years
https://www.canada.ca/en/revenue-agency/services/tax/individuals/topics/rrsps-related-plans/what-home-buyers-plan/repay-funds-withdrawn-rrsp-s-under-home-buyers-plan.html
By the way, you may be subject to tax instalment interest on the taxes
when you incurred those taxable capital gain.(assume the taxes on the taxable capital gain exceeded $3,000) A note of caution, depending on how long and how often you trade these stocks, CRA may considered them as INCOME Gain and the full amount is taxable.