1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Profit loss trading calculator for share market historical data

  1. Jul 7, 2013 #1
    1. The problem statement, all variables and given/known data

    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.

    2. Relevant equations
    The difference in Buy price to sell price times volume.

    3. The attempt at a solution
    Buy formula
    bank = bank - (10000 * sell) Remove money from bank to buy
    profit = profit - (10000 * sell) Value to take to sell formula for profit/loss

    Sell formula
    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.
    1. The problem statement, all variables and given/known data

    2. Relevant equations

    3. The attempt at a solution
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted