Look at that line: you define ma using the return of a function that already needs ma. This can obviously not work. You must fill a series with some content before you can use it.
Aside from that, may I ask how your code is supposed to work? Even if you fix all the typing mistakes - there are a lot more - the script still makes not much sense to me. How and when do you want to enter a trade?