Anyone write a Visual Basic program to help their trading?

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
 
'Sine Weighted Moving Average Indicator

Dim Period As Integer
Const PI = 3.1415926
Dim Factor, Num, Den, PreviousValue

Option Explicit
Public APP As OscUserApp
Implements Indicator

Public Sub Indicator_OnInitCalculate()
With APP
Factor = 180 / 6
.StartBar = Period - 1
PreviousValue = 0
End With
End Sub

Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
Dim i, SD
Num = 0
Den = 0
For i = 1 To Period
' Para pasarlo a radianes.
SD = ((i * Factor) * PI) / 180
Num = Num + Sin(SD) * .Close(i - 1)
Den = Den + Sin(SD)
Next i
If Den <> 0 Then
.SetIndicatorValue Num / Den
PreviousValue = Num / Den
Else
.SetIndicatorValue PreviousValue
End If
End With
End Sub

Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
Period = ParamList(1)
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
 
I find that Excel/VBA is good to start out but it is very system resource heavy and limiting once you have your system built. I like it for back testing and simple automation (currently using it for simple automation on a retail platform) but it's very crude and basic.

C++ and SQL would be much better - except I don't know those

a whole lot depends on your API as well as your trade. Excel can be perfect or it can really bog you down.
 
Quote from WinstonTJ:

I find that Excel/VBA is good to start out but it is very system resource heavy and limiting once you have your system built. I like it for back testing and simple automation (currently using it for simple automation on a retail platform) but it's very crude and basic.

C++ and SQL would be much better - except I don't know those

a whole lot depends on your API as well as your trade. Excel can be perfect or it can really bog you down.
Indeed. If you don't know how to configure Excel with all of it's settings options, you can go to 100% of CPU with realtime data. I confirmed the fact that I can write to the Windows registry about 3x faster than writing to a cell in a worksheet. That amazed me.
Excel's storage overhead on a sheet is huge.
 
traders studio realtime would be fantastic!
Yeah in general spreadsheet anything is worthless for less than five minute timeframe...
 
Quote from richardm:

traders studio realtime would be fantastic!
Yeah in general spreadsheet anything is worthless for less than five minute timeframe...

Um...I thought they were releasing a real-time version 2 or 3 years ago. Or am I mis-membering?
 
Quote from syswizard:


Exactly. VB/VBA has no "framework" for trading. You need a "platform" like Tradestation or WealthLab. Everything is built into it. With VB/VBA, you must build your own framework...this is NOT trivial.
Hi SysWiz'...

You mean the ability to click on something inside the platform and then trade at the bid or ask of a specfiic market... or chart the data...

or both?
 
Quote from richardm:

traders studio realtime would be fantastic!
Yeah in general spreadsheet anything is worthless for less than five minute timeframe...
Hi Rich'

worthless - if less than 5 minute timeframe - to do what?
 
Back
Top