Disliked{quote} Thanks man. This explains why I experienced a tiny bit of slippage when comparing my account balance and equity prior to hedge and after completion of this function. With manual multiple closeby, there is absolutely no slippage. I learnt a lot from this endeavor so thanks for generously sharing the code. It really helps to tweak and play around on your own to truly understand the inner workings of leveraged margin accounts. I bet many simply trade looking at charts without truly understanding. I know I was like that for over 4-5 yrs clicking...Ignored
Slippage can only occur in the order process. For example, if you're using a stop order with size to close out multiple positions then you'll likely get slippage because brokers like to slip large stop/market orders. Other than that there is no possibility to introduce any amount of slippage using this method.