How average cost is calculated?

Hi everyone,
Anyone can please let me know how Average cost is calculated .I will details my trade transaction.
On 11-06-2020 -bought 57 shares of SBIN for =176.50/-
On 12-06-2020-exited all 57 shares of SBIN at a loss of= 173.55/-(quantity was showing 0)
on 12-06-2020- bought 57 shares of SBIN at=174/-
Now my confusion is after my shares got converted to my holding average cost is showing in the portal=176.50 /- not 174 which was my last buying price.

Further now on 16-06-2020==
I exited my position all 57 shares of SBIN at a loss price=172.05/-(quantity was showing 0)
And again bought 65 shares of SBIN at lesser price of=171.90/-
My total average cost of shares should be my last traded price that is =171.90/-
But in the portal it is showing 175.93/-
How is the average cost calculated is this correct because according to me it should show 171.90/- not 175.93…

When you Sell and Buy shares that are in your holdings on the same day it is counted as intraday trade which has no effect on average price since no addition or deduction is happening to your holdings.

That is why your average price didn’t change for trades done on June 12.

On June 16 you again did the same thing as June 12, only when you bought shares back you bought 8 additional shares which brings average price down to 175.93 from 176.5 because here addition happened to your holdings.

But then again this calculation whatever is happening is not correct right because when i bought 65 shares
65x171.90/-=11,173.5/-
This much should get deducted from my account , but on further calculations i found out that inr 11,435.7/- was deducted from my account , why this 262.2 inr extra deducted from my account, is it some kind of hidden charges??

No hidden charges.

11435.7 is total value of your investment.

11173.5 is current value of your investment.

262.2 is loss on you investment.

Here is how average calculation is done -

57 * 176.5 = 10060.5
8 * 171.9 = 1375.2

10060.5 + 1375.2 / 65 = 175.93 ( Average Price)

That is only my question is why 57176.50 when i bought for 171.90,i already exited that position right.
on 12-06 i bought 57 for 174=57
174=9918
on 16-06 sold all 57 for 172.05= 57*172.05=9806.85

so (9918-9806.85)=111.5 loss which was already paid since when i bought the share for 9918 which amount was already deducted from funds and sold it at a lesser price 9806.85.

now on 16th i bought 65 for 171.9=65*171.9=11173.5 so instead of 11173.5 i was charged 11435, you are saying 262 is for loss…
can you please explain me for which loss of 262/- was got deducted.
If you see my post for the first time when i bought for 176.50 everytime its getting calculated with this value only even if i exit my position and buy for less price.

That is only my question is why 57 176.50 when i bought for 171.90,i already exited that position right.
on 12-06 i bought 57 for 174=57
174=9918
on 16-06 sold all 57 for 172.05= 57*172.05=9806.85

so (9918-9806.85)=111.5 loss which was already paid since when i bought the share for 9918 which amount was already deducted from funds and sold it at a lesser price 9806.85.

now on 16th i bought 65 for 171.9=65*171.9=11173.5 so instead of 11173.5 i was charged 11435, you are saying 262 is for loss…
can you please explain me for which loss of 262/- was got deducted.
If you see my post for the first time when i bought for 176.50 everytime its getting calculated with this value only even if i exit my position and buy for less price.

Already clarified it above.

Ok Then please clarify the 262 /- loss amount that was deducted extra.

Why i am asking this is because same selling and buying on the same day i did for some other shares as well there i did not faced this kind of issue, after selling with which ever price i bought same price was showing in the average cost.

This is Unrealised Loss, which you would be seeing in P/L column in Holdings.

Current price of SBI is 184.5, if you are still holding you should be seeing profit of 557 in holdings.