How can I get better ratings when drawing spells?

You are correct, speed and accuracy are the key factors when casting spells. This Youtube video does a great job explaining the importance of the two, and below are the highlights on how they effect the trace meter.

Speed
The meter will start decreasing the moment you being your tracing. The meter will continue to decrease until your finger is released from the screen.

Accuracy
If your spell was successfully drawn, then the meter will increase or decrease based on how accurate you were. If the trace is accurate, the meter will increase. However, if the trace is way off target, it may decrease the meter even further

As you draw, you may notice the trace line is green as some points. This means that portion was the most accurate it could be (despite it may be little off the line by a little).

Potions
The Youtube video didn't cover this, but another factor to keep in mind is potions. There are some potions, such as the Wideye, that will help improve the speed and accuracy of your trace