I need a relatively simply algorithm built, designed to repeatedly buy X number of shares when the share price increases by Y% and sell X number of shares when the share price decreases by Y%. I would like this to be an ongoing command. So, theoretically, the code would sell high and buy low multiple times a day. I am new to coding, and I could use a little guidance. 

Thank you,

Ryan