Learn how the average price is calculated on Dhan!

If you buy/sell a stock at the different price levels you will see that the average price changes. So how does it change, and who decides it? Let’s understand with an example.

Assume you bought 10 shares of Tata Motors on 13/04/2022 and the other 20 shares on 15th April and sold 5 Qty on 17th and repurchased it on 20th at different prices as mentioned in the table.

Here the average price of the TAMO will be calculated as (Qty*price)

= (10400)+(20440)-(5463)+(25430) = 21235 divided by total Quantity i.e 50.

Your Avg price will be = 21550/50

= Rs. 431/-


  • This process of averaging follows the FIFO rule (First In First Out). Meaning, the shares which you have bought first would be considered first while selling
  • FIFO is followed even in BTST (Buy Today Sell Tomorrow)

Hey @Sudhanshu,

It would be good idea to have an example with buy/sell over total of 5-6 transactions.

Hi, @amit noted your request. Doing it right away.

1 Like

Hey @Sudhanshu,

Not sure if sell transaction should be included in the weighted average formula to derive the average price…

Can you please take a look at following calculation and share your comments.

1 Like

Hi @amit Your sell price is also considered while calculating the average buy price of the security

@Sudhanshu ,

I see that you’ve updated the formula and now the average price is same as mine…

I’m glad that my calculation was useful… :slightly_smiling_face:

HI @Sudhanshu , here is an example of Crude oil transactions .

CRUDEOIL–> Sold at 200 rs → Bought back at 160 → Again Sold at 145 .

All these transactions happened on the same day.

Now since it was sold at 200 and bought back at 160 . Supposed to be in profit but not realised right? would that amount be calculated at the end of day and added to account?

My doubt is when the same strike price is sold and bought back multiple times there seems to be a Glitch in DHAN. could you please check on this?

Hi @pavz , If you have partially bought or sold any of your position on the same day. the p&l is shown on the basis of the average entry price.

If you witness some glitch please report this at help@dhan.co

Yes same day 3 transactions were done and the final thing was holding.

So in my case my avg price is around 145 which is displayed. is that correct?

1 Like

Yes @pavz, its correct.

@iamshrimohan @RahulDeshpande @PravinJ

Hi, these trades happened yesterday .
Please see the screenshots .
Out of 8400 Quantity->AVG PRICE : 11.39 → MCX 1640 CE → Bought back 4000 @6.88
Holding 4000

So there is a Profit of 26K which is realized in the same Strike price , but this is not seen in TRADERS DIARY.

My doubt is yesterday end of day my overall profit is 20k around, but i do not see that being reallized in traders diary and overall positons in MCX is displayed in negative.

I feel when the same Stirke prices is sold and bought multiple times and hold those at the end of the day ( there is a glitch in dhan i feel, when we completely close the position , no issues though)

This is what i see today morning

My Concern is
1 .TRADERS DIARY - > Not capturing partial booked profits
2. Though the overall profit is 20k at the end of market closing , now the same are in neagative?

Where is the profit amount being adjusted? is it in Margin in this case?

Added the exact same trades with and updated the avg price on opstra (Positon in overall profit is shown negative by a huge difference) +16k to -8K :upside_down_face: :roll_eyes:


1 Like