We need help building logic for trade review automation

Job ID: 37126813

Budget: $250 – $750 CAD

Consistency Logic

Any trades taken within 60 seconds of one another is considered to be one single trade.
Any single trade with a profit above 25% of the total Net Profit earned is a breach of the consistency rule
Consistency rule no longer applies to trades taken 90 days after the first trade is placed

Issue we are having with the logic for automation.
We need to group trades taken within 60 seconds of one another and sum the total net profit.
I will outline an example below with trades numbered taken and grouped.

1:02:03 $100
1:02:15 $600
1:02:32 $350
1:02:38 $800
1:02:56 $1200
1:03:06 $300
1:03:29 $250
1:03:35 $650
1:03:50 $450

In this example Trades 1-5 would be grouped in group 1 for a sum of $1850
Then trades 2-6 would be grouped in group 2 for a sum of $3,250
3-7 would be grouped in group 3 for a sum of $2,600.
4-8 would be grouped in group 4 for a sum of $3,200
5-9 would be grouped in group 5 for a sum of $2,850

At first glance the logic seems simple. However, the issue comes with trades 5,6,7. Trade 5 would be included in groups 1-5. Trade 6 would be in groups 2-5. Trade 7 would be in groups 3-5. Trade 8 would be in groups 4 and 5.

This makes it difficult when creating the group identifiers in excel especially when someone is using an EA where there may be several trades in 10, 15 different groups.
Also let’s say for example Group 2 and 4 are in violation of the consistency rule. The actual total profit in violation of the rule would need to be adjusted so that the same trade isn’t counted twice in the profit.