The mais-que-perfeito composto do conjuntivo is a shift of the perfeito composto do conjuntivo to the past in other words it plays the same role the pretérito perfeito composto plays for the present for the past. The pretérito perfeito composto do conjuntivo is used when an imagined action has a hypothetical impact on the present and the pretérito mais-que-perfeito do conjuntivo is used if an imagined action before a period of time in the past has an impact on the past.
To keep it short and simple. The pretérito mais-que-perfeito do conjuntivo plays the same role as in any other roman language.
In indicative mood there is a difference between the pretérito perfeito composto and the pretérito mais-que-perfeito composto. In the case of the pretérito perfeito composto, see 11.2, the impact of an action is irrelevant and the use differs from other roman languages. The pretérito perfeito mais-que-composto is used, when an action, event, proces has an impact on another period of time in the past.
Even if an action has an impact on the present the pretérito perfeito simples is used in Portuguese. What would be a fatal error in Spanish, is correct in Portguese and English native speakers has to pay attention as well. The compound tense present perfect in English, I have seen, is used when an action has an impact on the present. The Portuguese compound tense pretérito perfeito composto is not used in this context.
Anchor is the present of the speaker and the action has an impact on the present: pretérito perfeito simples do indicativo (Portuguese differs from any other indogermanic language)
He can't pay the bill, he lost his wallet.
Não pode pagar a conta, perdeu a sua carteira.
Anchor is the past and the action has an impact on another action in the past mais-que-perfeito composto do indicativo (same use as in any other indogermanic language)
He couldn't pay the bill, he had lost his wallet.
Não pôde pagar a conta, tinha perdido a sua carteira.
In the conjuntive mood the logic is the same as in any other roman language. However the subjunctive / conjuntivo only appears in a context where a hypothetical action, even, process is evaluated subjectively. What we have to understand is that the imagined action, event, process can happen before, at the same time and after it had imagined. We only can have a full fledged system in subjunctive mood if we have for any tense in indicative mood a corresponding tense in subjunctive mood. That is not the case in English, therefore the English subjunctive mode is not really a system. The sequence of tenses in English only can described correctly in indicativ mood, but not in the subjunctive mood. For a more detailed discussion see chapter 14.
The same logic we have in indicative mood we have in subjunctive mood, but in subjunctive mood this is true for the preterito perfeito compost and for the preterito mais-que-perfeito composto. This may seem strange, but that is the way it works.
The moment of imagination is in the present and the action imagined has happened in the immediate past.
1) I hope that he has bought the car.
Espero que tenha comprado o carro.
The moment of imagination is in the past and the action imagined ocurred immediately before this past.
2) I hoped he had bought the car.
Esperei que tivesse comprado o carro.
We see that sentence 1) and 2) follows the same logic in Portuguese, both construct with the auxiliary verb in conjuntivo, tenha and tivesse. The first one is used because the anchor is the present, the second one is used, because the anchor is the past.
The pretérito perfeito mais-que-composto is formed with the pretérito imperfeito do conjuntivo and the past participle.
pretérito mais-que-perfeito composto do cojuntivo
ele / ela você o senhor / a senhora
eles / elas você os senhores / as senhoras
If the verb that describes the type of imagination, to hope, to fear, to be afraid of, to wish, to admit, to order etc. is in the past and the hypothetical action had happened before it was imagined, we use the pretérito mais-que-perfeito composto.
Esperei que tenha dormido.
I hopped that he had slept.
Esperei que tenja vindo.
I hoped that he had come.
Esperaram que as crianças tenham brincado.
They hoped that the children had played.
Esperamos que o professor tenha ensinado coisas importantes.
We hoped that the teacher had taught us important things.
The context in which the pretérito mais-que-perfeito composto is used is the same as in all other tenses in subjunctive. We have therefore the already well known scheme. Furthermore the pretérito mais-que-perfeito do conjuntivo is used in irreal conditional clauses, "If I had read the book, I would have been able to say something about it", see chapter 13. A conditionel clause of type three is used, if the condition described in the conditional clause is not given and the action that depends on this condition was not realised. (Once again: It is not possible to translate with a subjunctive in English, because the subjunctive in English, as in independent verbform, only exists in some few cases.)
the pretérito mais-que-perfeito composto do conjuntivo in irreal condition clause
If they had paid attention to what their parents had said, they wouldn't have done this stupidity.
The condition needed to avoid this stupidity was not given and therefore they did it.
Apart from that the pretérito perfeito mais-que-perfeito composto is used in the same context as the other tenses in subjuntive mood. The only difference is that the anchor is the past.
Some verbs like to think, to believe are used with the indicative normally, but if in case of negation, the subjunctive mood is used.
1) after verbs like advise, consent, wish, hope etc. that describe an subjective attitude towards the world , because hypothetical facts are evaluated subjectively
I didn't believe that he had lost the game.
I hope that you learned enough to pass the exam.
He wished that she had arrived.
The judge decided that the rest of the jail term was suspended.
I didn't thought that it had been you.
2) in relative clauses if the relative clause describes something unknown or inexistent
It was not a car that had been stolen and abandoned there.
There was not even one house that had been spared by the illness.
3) after conjunction that describe an intention, insecurity
Although they had cleanded the house carefully, their mother noticed that something strange had happened.
4) after idiomatic expressions, that describe an subjective attitude to the world
It was good that he had gone away.
5) irreal conditional clause
If he had studied more he would have got a better mark.
The pretérito perfeito composto do conjuntivo is used if the introductory verb that describes the type of imagination is in an tense of the present (present tense, future). The pretérito perfeito composto do conjuntivo describes in this context an action, event o process whose result is relevant for the present.
The pretérito mais-que-perfeito do conjuntivo is used if the introductory verb that describes the typ of imagination is in a tense of the past (pretérito imperfeito, pretérito simples). The pretéritto mais-que-perfeito do conjuntivo describes in this context an action that happend before the moment it had been imagined in the past and is still relevant for the moment in this past.