How to open a trade position at a bar added to the cureent chart and time frame?

 

Hi

I'm new to the MQL4 and I would like to know how can I add a trade position or do some calculations at a new candle opening ?

Thanks for any help