I understand that you are not sure how to write MATLAB code with multiple functions in one file.
First a function with the same name as the name of the m file needs to be written. This will be the main function. Below this function define all other functions may be defined. The code structure should look something like this:
function [outputs] = getData(inputs)
function [outputs] = ProfitOrLoss(inputs)
function [outputs] = calculatePercent(inputs)
One helper function may be called from another helper function too. All helper functions (getData, ProfitOrLoss, calculatePercent) must be written below main function.