How can I determine my cryptocurrency exchange rate according to demand and supply by programmatically? I know exchange rate depends on so many factors theoretically, but how can I determine my cryptocurrency exchange rate according to demand and supply by programmatically?

Is there any standard algorithm to increase and decrease the value of cryptocurrency(ex. in USD) based on demand and supply?

How Bitcoin exchange rate increase and decrease automatically, Please let me know, is there any algorithm which can estimate the value of Bitcoin in USD and increase/decrease it's value(in USD) automatically.
Price of bitcoin is determined by the traders 
Suppose there are 2 Traders Person X and Person Y 
Then consider the following use case. 


  1.If person X has N amount of bitcoins and then he can choose to sell them at P amount of price.
  
  2.Person Y wants to purchase the Bitcoin then he can choose to bye N amount of bitcoins for price P1.
  
  3.If P=P1 then N amount of bitcoins are transferred to account of Y.
  
  4.In the same way if the Buyers are decreasing the price and continuously finding the sellers for descried price then the price
  goes on decrising
  
  
  Vise-versa if the sellers are incising the sell price and continuously finding the buyers for increased price then the price of
  bitcoin goes up.
  The third condition which rarely occurs is If sellers trade and buyer trade is not matching then the price of bitcoin is determined to
  the midpoint of lowest sell order and highest buy order.
  
  
  ie. If highest bye order is for 10L/BTC and lowest sell order is for
  15L/BTC then the price will be set to 12.5L/BTC and users will trade
  according to that.