programmatically add an existing entity reference autocomplete field in custom form
If you are using the references module's node_reference field, then, in your custom form, you'll want to create a field that uses the node_reference's autocomplete, like so:

$form['referenced_field'] = array(
  '#title' =&gt; 'Referenced field title',
  '#description' =&gt; t('Referenced field description.'),
  '#type' =&gt; 'textfield',
  '#autocomplete_path' =&gt; 'node_reference/autocomplete',
  '#required' =&gt; TRUE,  // Optional depending on your circumstance.
);


See node_reference.module line 892 for more details on parameters, etc.