The margin is calculated based on the current total value of all the securities in the margin account. The stockbroker sets a margin limit to calculate the overall leverage you can get. For example, if the margin limit percentage is 50%, and the total value of the securities is Rs. 2,00,000, you can borrow Rs. 1,00,000 (50% of Rs. 2,00,000) as a margin.