@ otl,
I incorporated your function, then refactored the Names for better self-documentation.
I think that the output will be unusable as designed. We have two Tiks to consider, the TimeTik of once per second and the UpdateTik at around 20-50 updates per second.
The issue I see ATT is that at the start of the Second, the UpdateTic count is 1 resulting in an output of 0.2
At the end of a Second, the Update Tik count may be as high as 50, resulting in an output of 4.0.
Option Explicit
'Sub Worksheet_Change()
'If Target = C3 Then
'MilliSecondsPerUpdate.Tik = C3 'C3.Value in whole Seconds
'End If
'etc..
'End Sub.
' clsMilliSecondsPerUpdate Code
Dim LastSecond As Date
Dim CurrentSecond As Date
Dim TikCount As Long
Dim Tik As Date
Dim PreviousMilliSecondsPerUpdate As Double
Private pMilliSecondsPerUpdate As Double
Public Property Let Tik(UpdateTime As Date)
CurrentSecond = UpdateTime
If CurrentSecond = LastSecond Then
TikCount = TikCount + 1
Else
LastSecond = UpdateTime
End If
CalculateMilliSecondsPerUpdate
End Property
Private Sub CalculateMilliSecondsPerUpdate()
If CurrentSecond = LastSecond Then
'ms per update in this second
PreviousMilliSecondsPerUpdate = 1000 / TikCount
Else
'ms per update in last whole second
pMilliSecondsPerUpdate = PreviousMilliSecondsPerUpdate
'Reset times and counts
TikCount = 0
LastSecond = CurrentSecond
End If
End Sub
Public Property Get EMAFormulaModifier()
'Used as Modifier for Certain Formulas per otl
' Assuming Ema Constants set for 200ms Update
EMAFormulaModifier = 200 / pMilliSecondsPerUpdate
'Ms/Update is a ramping Curve... /|/|/|
'This means that the modifier is the inverse... \|\|\
' The vertical bars represent TimeTiks or seconds
End Property
Option 1: Run the Helper App once per TimeTik
Option 2: :
I'm going to look at some micro-timers to see what I can do.