Counting profit / loss

It's hard to provide more guidance without a reproducible example, called a reprex FAQ: What's a reproducible example (`reprex`) and how do I do one?. In this case, it would be a great benefit if the data were in an easier form to work with.

In this case, assuming the data frame is named entry_orders, simply


and you can cut and paste code that will recreate what you are working with.

Assuming there were one, it would be possible to show how to use mutate(variable = some_variable - lag(some_variable).