Hello,

My objective here may be confusing if you don't understand trading in a brokerage 'cash' account.

I am trying to write a macro that finds the trade that triggers a 'free riding' violation.
Here is an example of what a free ride violation...

• The situation: Mr. Smith starts day zero (the trade date) with $100 of settled cash in his account, and buys $1,000 of XYZ stock. The remaining $900 needed to fully pay for the trade is due by the settlement date, day three (T+3). On the day before settlement (T+2), before fully paying for the security with settled funds, Mr. Smith sells his XYZ shares for $1,500.
• The violation: Because Mr. Smith sells the stock before paying for its purchase, the sale results in a freeriding violation.
• The consequence: Industry regulations require the account to be placed on a settled-cash-up-front restriction for 90 days, during which time trading is restricted to the amount of settled funds available. Brokerage firms cannot waive this restriction (Industry Rule). However, if funds are deposited promptly (within the payment period) to cover the entire purchase, the violation may be downgraded to a good-faith violation.

THE GOAL

I want my macro to be able to look at the settlement dates and differentiate between settled and unsettled funds and calculate it in different columns respectively.
the goal would be a message box that shows the transaction that caused a violation by the means of reconciling the settled and unsettled cash
(If a sale is done after an unpaid purchase)...

Can anyone give any guidance or direction on this...?
Please see the attachment for a visual

Any insight would be greatly appreciated!