I have an X50. You can't do what you want with it, sorry.
You can program a pattern into one of the arpeggiators in advance, then play it back as long as you want. You can also transpose the playback of that arpeggiator based on the notes you're playing in real time. What the X50 *can't* do is loop real-time input from the keyboard.
If the notes you want to loop are fixed (i.e., you're not going to improvise), you could program them into the arpeggiator in advance and play that during your song. Honestly I don't even recommend that, though - custom arpeggiator programs are a pain in the @ss to write on the X50, and you may not be able to write your entire loop anyway, depending on the tempo and time signature.