Field History : how to detect in apex which fields are tracked?
Since Winter '16 this can be achieved using the IsFieldHistoryTracked field on FieldDefinition.
To get all tracked fields on Account you can use:
SELECT QualifiedApiName FROM FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Account' AND IsFieldHistoryTracked = true
There is another question however the solution was not accepted as an answer: Apex: Is there a way to Identify if history tracking is enabled on my field or not?
I think there is no clean way of doing this.
Every object that has history enabled has a special table by the name "Custom_Object_History" or "StandardObjectHistory".
You can run the following query on that object:
SELECT count(Id),Field FROM Custom_Object__History group by Field
The result will be something like
Count Field
1 Contract_Term__c
12 Contract_Expiry_Date__c
1 Type_of_Service__c
Using this you can get the field API names.
If your field API Name is present, the you have History Enabled on that field.
This may however give you the field history for past as well. You can put a date clause I guess.