From my experience, the best way for a beginner is describing the algorithm in natural language, just as if you would explain it to someone else who has absolutely no clue of trading. Then try to convert that description into code. If you run into problems, just ask here. Analyzing MT4 scripts is often a waste of time.