Pilot on a training flight reported an NMAC as a result of confusion and flying the wrong altitude.
Synopsis
Pilot on a training flight reported an NMAC as a result of confusion and flying the wrong altitude.
Narrative
Day 0 at XB:37 UTC time; I was on the way from ZZZ1 and heading to ZZZ for touch and goes.I contact ZZZ approach at XA:37 UTC time and I hear the ATIS at XA:39 UTC time; and according to my personal ATC recording; it started at XB:37UTC.ZZZ approach gave me an instruction 'at or above 5500 ft' to avoid the traffic. (XB:39 UTC)Therefore I found the traffic and replied 'Traffic in sight' and complied by keeping altitude 5500 ft. (XB:39 UTC)Right after; he gave me another instruction 'Aircraft X; roger maintain visual separation that traffic; maintain VFR at or above 4500 additional traffic; Aircraft Y; 12'o clock 4miles south bound 4000' (XB:40 UTC)So I confused to keep that altitude and I thought that I keep that altitude at or above 4500 and I saw the traffic in front of me Aircraft Y. so I turned right to avoid traffic. But I realized ZZZ approach wants me to keep more vertical separation with that traffic. After touch and goes from ZZZ on the way back to ZZZ2 airport; I got possible pilot deviation from ZZZ departure. (XC:04 UTC)Since I said 'traffic insight'; I aware of that I have a responsibility to maintain good separation; and for the future I'll keep in mind to comply with it more strictly. I had a big lesson this time and I'll have a ground school and a dual flight training to improve and not to let this happen again.
Source: NASA Aviation Safety Reporting System (public domain). Reports are voluntary submissions and are not verified by NASA.