I've talked a lot about the importance of writing for the audience; I've even gone so far as to say: "You don't even have to like your own movie as long as your audience does." And even though I know that statement might strike a sour taste in a lot of people, when it comes to making movies, it's the audience that buys the tickets. They are the customers, so we must keep them in mind – always.
However, to expect that we write for the audience first and foremost in every circumstance is premature to say the least. When I wrote my first feature screenplay, I'd be lying if I said I was focused on the mainstream audience. My script was an indie comedy/drama/musical about a struggling gay opera singer who finds acceptance in the last place he expects when he joins a rock-n-roll band. It was never sold, never optioned, but it was a great spec writing sample and got me in more than my fair share of meetings. No one wanted to make the movie because no one could figure out who exactly the audience was or how to market it, but the script did show producers I could write with a voice. And that fact alone opened the doors again for the next script and the next.
Simply put, I learned the craft of screenwriting by listening to my own voice, following my own passions, and writing from within. It wasn't until much later that I took what I had learned and applied it so that I could write for the masses.
The reality is that most screenwriting work in Hollywood is on-assignment, and when you're being paid to write a movie, writing for the audience truly is everything. If it's a personal passion project, however, the audience is still of paramount importance – you want to involve them as much as possible – but now you're writing for yourself, and you don't have to alter things to satisfy executives, producers, the director, or whomever.
So, unless you're getting paid, my advice is to always write what you like – stories that you get a kick out of. Write a movie that you want to watch, one in which you would be first in line to go see. Believe in yourself, have a strong point of view, and always be conscious of your inner voice; some stories just demand to be told.