For example, if the initial cash is $1,000, buy $500 when the stock price crosses MA5 for the first time, buy another $500 when the stock price falls to MA10, stop loss and exit when the stock price falls to MA20, and take profit and exit when there is a 20% profit.
Thank you.
I hope to have a simple Python example to illustrate my needs.