Account History for P\L summary

Does any one know the best way to get order history for one symbol for the previous or current month with a total profit/loss by pips and currency?

Much thanks in advance!!

You can do something similar to this -> https://www.mql5.com/en/code/8126. Change the code for the functionality u need.
Thank you!!