I have an INDEX array function :
"=INDEX(FREQUENCY(FREQUENCY(IF(C2:C45000,ROW(C2:C45000)),IF(C2:C45000<>"TRUE",ROW(C2:C45000))),{0,1}),2)"
to count how many consecutive TRUE values I have. This works great in counting a straight forward list, however i need to combine it to only count the consecutive TRUE values if something is turned on. I have tried to add an IF function to the beginning:
"=IF(D2:D45000>0,(INDEX(FREQUENCY(FREQUENCY(IF(C2:C45000,ROW(C2:C45000)),IF(C2:C45000<>"TRUE",ROW(C2:C45000))),{10,1000}),2)))"
but this does not work. Ideally I want the above IF to count consecutive values if Dx>0 but if D=0 then skip over that value (even if it is TRUE) and proceed to the next.

Any suggestions?