Share market trading calculator.
I have tried to write code to calculate the buy and sell with profit/loss on historical data using moving averages. I'm am not interested in leverage yet.
bank = 10000
equity = 10000
sell = is current price of an instrument on the stock market either in the buy or sell routine.
The difference in Buy price to sell price times volume.
The Attempt at a Solution
bank = bank - (10000 * sell) Remove money from bank to buy
profit = profit - (10000 * sell) Value to take to sell formula for profit/loss
profit = equity + ((10000 * sell ) + profit) Find profit/loss and compare against Buy
bank = profit: profit = 0
It works for a single buy and sell but I can't work out how to add more buys and sells to the bank or what to do with equity.