I am calculating my e-Value for my own BLAST alignment.

I used the formulae: e= mn2^-S'

where:
m = length of the query sequence
n = total number of lengths of all template sequences in the template file
S' = bit score.

I was wondering about parameter n: Do I need to sum all lengths of template sequences which are involved in the alignments or do I need to sum all lengths of _all_ template sequences and it doesn't matter if they are in the alignment involved or not?

The E-value is an estimate of the expected number of alignments that you would get with the given bit score or higher by random chance alone. So to calculate n, you need to sum the lengths of all template sequences, regardless of whether they are involved in the alignment or not.

Also, there's no way that the E-value, as you defined it, can be negative. If S' is a real-value then 2^{-S'} has to be positive. Perhaps you are thinking of log(E)?

Additionally, I'd like to know if the e-Value should be abs(e-Value)? Because it can be negative.