@mandy welcome to AmiBroker, glad that you are trying to learn. I have not seen any code from you that shows where you are having a problem? I have not seen your code for "Buy" and "Sell", nor have you shown the forum that you are a properly licensed user. Once you get that badge and show your codes I am sure someone on the forum will help fix your code efforts.
Good luck and once again welcome to the AmiBroker community.