ATR volatility stop for ya...
tradestation and multicharts are great, but look at all of the proprietary junk they stiffarm you with, here is a simple ATR indicator from Visual Chart 5 complete with initialization and error checking - - yes, some namespace dependencies here in term of plotting, but hey at least it is very, very workable...
Dim ATRRange As Long
Dim Factor As Double
Const Data As Long = 0
Dim AvTrueRangeData As Long
Option Explicit
Public APP As OscUserApp
Implements Indicator
Public Sub Indicator_OnInitCalculate()
With APP
AvTrueRangeData = .GetIndicatorIdentifier(AvTrueRange, Data, ATRRange)
.StartBar = 0
End With
End Sub
Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
.SetIndicatorValue .Close - .GetIndicatorValue(AvTrueRangeData) * Factor
.SetIndicatorValue .Close + .GetIndicatorValue(AvTrueRangeData) * Factor, 2
End With
End Sub
Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
ATRRange = ParamList(1)
Factor = ParamList(2)
End Sub
Public Sub Indicator_OnCalculateRange(ByVal StartBar As Long, ByVal FinalBar As Long)
Dim i As Long
i = APP.StartBar
If StartBar > i Then
i = StartBar
End If
While Not APP.ShouldTerminate And i <= FinalBar
APP.CurrentBar = i
Indicator_OnCalculateBar i
i = i + 1
Wend
End Sub
Private Sub OscUserAppInstance_OnConnection(ByVal Application As OscUserApp, ByVal MTDllInst As Object, Custom() As Variant)
Set APP = Application
End Sub
tradestation and multicharts are great, but look at all of the proprietary junk they stiffarm you with, here is a simple ATR indicator from Visual Chart 5 complete with initialization and error checking - - yes, some namespace dependencies here in term of plotting, but hey at least it is very, very workable...
Dim ATRRange As Long
Dim Factor As Double
Const Data As Long = 0
Dim AvTrueRangeData As Long
Option Explicit
Public APP As OscUserApp
Implements Indicator
Public Sub Indicator_OnInitCalculate()
With APP
AvTrueRangeData = .GetIndicatorIdentifier(AvTrueRange, Data, ATRRange)
.StartBar = 0
End With
End Sub
Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
.SetIndicatorValue .Close - .GetIndicatorValue(AvTrueRangeData) * Factor
.SetIndicatorValue .Close + .GetIndicatorValue(AvTrueRangeData) * Factor, 2
End With
End Sub
Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
ATRRange = ParamList(1)
Factor = ParamList(2)
End Sub
Public Sub Indicator_OnCalculateRange(ByVal StartBar As Long, ByVal FinalBar As Long)
Dim i As Long
i = APP.StartBar
If StartBar > i Then
i = StartBar
End If
While Not APP.ShouldTerminate And i <= FinalBar
APP.CurrentBar = i
Indicator_OnCalculateBar i
i = i + 1
Wend
End Sub
Private Sub OscUserAppInstance_OnConnection(ByVal Application As OscUserApp, ByVal MTDllInst As Object, Custom() As Variant)
Set APP = Application
End Sub