log of daily returns, ATR, Parkinson, Garman-Klass, etc.
from my experience a big problem they all have is that by only looking at one time slice (ie, daily data) they miss much of the the back and forth movement. what i had created in excel to calculate this was a indicator to tell me the total number of ticks traded over a given time period.
on any given bar price can only take 2 paths to the close.
open->high->low->close or open->low->high->close
below is the vba code i use in excel to track the tics traded
it first checks the open->high->low->close path
hedgeTick is a variable i can set. it can be set to the minimum tick increment or a larger value to see count the number or moves of a given size (say if i want to hedge s&ps every 10 points).
it then checks the open->low->high->close path. since even on 1 minute data you can't be sure which path price took i then take the minimum of the 2.
i have found this indicator to be of much greater value in my options trading as it gives you a real sense of the number of tics (or deltas) that a security trades over the course of a day.
i started trying to code this in ninjatrader but am still at the early part of the learning curve. i think since it requires a data history to check against it would require me to set up variables using
new DataSeries(this);
in the
protectedoverridevoid Initialize() section
but im a bit lost at how to proceed. if someone had an idea how to get this started any help would be greatly appreciated.
------------------------------------------------------------
refCheckOHLC = prevClose
refCheckOLHC = prevClose
ohlcSum = 0
olhcSum = 0
If (check = 1) Then
'Check O->H->L->C First
' PREV CLOSE -> OPEN
If (cOpen - TickSize) > refCheckOHLC Then
If ( ((cOpen - TickSize) - refCheckOHLC) / hedgeTick) >= 1 Then
ohlcSum = ohlcSum + Int( ((cOpen - TickSize) - refCheckOHLC) / hedgeTick)
refCheckOHLC = refCheckOHLC + Int( (((cOpen - TickSize) - refCheckOHLC) / hedgeTick))
End If
ElseIf (cOpen + TickSize) <= refCheckOHLC Then
If ( (refCheckOHLC - (cOpen + TickSize)) / hedgeTick) >= 1 Then
ohlcSum = ohlcSum + Int( (refCheckOHLC - (cOpen + TickSize)) / hedgeTick)
refCheckOHLC = refCheckOHLC - Int( (refCheckOHLC - (cOpen + TickSize)) / hedgeTick)
End If
End If
' OPEN -> HIGH
If (cHigh - TickSize) > refCheckOHLC Then
If ( ((cHigh - TickSize) - refCheckOHLC) / hedgeTick) >= 1 Then
ohlcSum = ohlcSum + Int( ((cHigh - TickSize) - refCheckOHLC) / hedgeTick )
refCheckOHLC = refCheckOHLC + Int( ((cHigh - TickSize) - refCheckOHLC) / hedgeTick )
End If
End If
' HIGH-> LOW
If (cLow + TickSize) < refCheckOHLC Then
If ( (refCheckOHLC - (cLow + TickSize)) / hedgeTick) >= 1 Then
ohlcSum = ohlcSum + Int( (refCheckOHLC - (cLow + TickSize)) / hedgeTick)
refCheckOHLC = refCheckOHLC - Int( (refCheckOHLC - (cLow + TickSize)) / hedgeTick)
End If
End If
' LOW -> CLOSE
If (cClose - TickSize) > refCheckOHLC Then
If ( ((cClose - TickSize) - refCheckOHLC) / hedgeTick) >= 1 Then
ohlcSum = ohlcSum + Int( ((cClose - TickSize) - refCheckOHLC) / hedgeTick )
refCheckOHLC = refCheckOHLC + Int( ((cClose - TickSize) - refCheckOHLC) / hedgeTick )
End If
End If
check = 2
End If
If (check = 2) Then
'Check O->L->H->C Second
' PREV CLOSE -> OPEN
If (cOpen - TickSize) > refCheckOLHC Then
If ( ((cOpen - TickSize) - refCheckOLHC) / hedgeTick) >= 1 Then
olhcSum = olhcSum + Int( ((cOpen - TickSize) - refCheckOLHC) / hedgeTick )
refCheckOLHC = refCheckOLHC + Int( ((cOpen - TickSize) - refCheckOLHC) / hedgeTick )
End If
ElseIf (cOpen + TickSize) <= refCheckOLHC Then
If ( (refCheckOLHC - (cOpen + TickSize)) / hedgeTick) >=1 Then
olhcSum = olhcSum + Int( (refCheckOLHC - (cOpen + TickSize)) / hedgeTick)
refCheckOLHC = refCheckOLHC - Int( (refCheckOLHC - (cOpen + TickSize)) / hedgeTick)
End If
End If
' OPEN -> LOW
If (cLow + TickSize) < refCheckOLHC Then
If ( (refCheckOLHC - (cLow + TickSize)) / hedgeTick) >= 1 Then
olhcSum = olhcSum + Int( (refCheckOLHC - (cLow + TickSize)) / hedgeTick)
refCheckOLHC = refCheckOLHC - Int( (refCheckOLHC - (cLow + TickSize)) / hedgeTick)
End If
End If
' LOW-> HIGH
If (cHigh - TickSize) > refCheckOLHC Then
If ( ((cHigh - TickSize) - refCheckOLHC) / hedgeTick) >= 1 Then
olhcSum = olhcSum + Int( ((cHigh - TickSize) - refCheckOLHC) / hedgeTick)
refCheckOLHC = refCheckOLHC + Int( ((cHigh - TickSize) - refCheckOLHC) / hedgeTick)
End If
End If
' HIGH -> CLOSE
If (cClose + TickSize) < refCheckOLHC Then
If ( (refCheckOLHC - (cClose + TickSize)) / hedgeTick) >= 1 Then
olhcSum = olhcSum + Int( (refCheckOLHC - (cClose + TickSize)) / hedgeTick)
refCheckOLHC = refCheckOLHC - Int( (refCheckOLHC - (cClose + TickSize)) / hedgeTick)
End If
End If
check = 1
End If
If (ohlcSum < olhcSum) Then
tics = tics + ohlcSum
refCheckOLHC = refCheckOHLC
Else:
tics = tics + olhcSum
refCheckOHLC = refCheckOLHC
End If
olhcSum = 0
olhcSum = 0
Comment