PureBytes Links
Trading Reference Links
|
If you are a VB programmer and you would like to code studies in an open
language like shown below please contact me. I am thinking of sponsoring
several experienced programmers that can help with coding and examples and
wish to provide add on products. Thanks Mark
ps we speak french
==============================================
Sub SystemTestEntry()
Call TWApp.Message("Moving Average Crossover")
Call TWApp.Message(twSymbol & " from " & twStartDate & " to " &
twEndDate)
Dim sFormula
Dim MAPeriod1()
Dim MAValid1()
sFormula = "MOV(c, 5, s)"
Call TW.CalculateFormula(sFormula, twHigh, twLow, twOpen, twClose, twOI,
twVolume, MAPeriod1, MAValid1)
Dim MAPeriod2()
Dim MAValid2()
sFormula = "MOV(c, 10, s)"
Call TW.CalculateFormula(sFormula, twHigh, twLow, twOpen, twClose, twOI,
twVolume, MAPeriod2, MAValid2)
For i = 2 to UBound(MAPeriod1, 1)
If MAValid1(i) = 1 AND MAValid2(i) = 1 Then
If MAPeriod1(i) > MAPeriod1(i-1) AND MAPeriod1(i-1) < MAPeriod1(i-2)
Then
Call TWApp.Trade(twSymbol, twDate(i), 1000, twBUY, twClose(i))
ElseIf MAPeriod1(i) < MAPeriod1(i-1) AND MAPeriod1(i-1) >
MAPeriod1(i-2)
Then
Call TWApp.Trade(twSymbol, twDate(i), 1000, twSELL, twClose(i))
End If
End If
Next
End Sub
================================================
Sub SystemTestEntry()
Call TWApp.Message("Moving Average Crossover Variable")
Call TWApp.Message(twSymbol & " from " & twStartDate & " to " &
twEndDate)
Dim sFormula
Dim MAPeriod1()
Dim MAValid1()
sFormula = "MOV(c," & P1 & ", s)"
Call TW.CalculateFormula(sFormula, twHigh, twLow, twOpen, twClose, twOI,
twVolume, MAPeriod1, MAValid1)
Dim MAPeriod2()
Dim MAValid2()
sFormula = "MOV(c," & P2 & ", s)"
Call TW.CalculateFormula(sFormula, twHigh, twLow, twOpen, twClose, twOI,
twVolume, MAPeriod2, MAValid2)
For i = 2 to UBound(MAPeriod1, 1)
If MAValid1(i) = 1 AND MAValid2(i) = 1 Then
If MAPeriod1(i) > MAPeriod1(i-1) AND MAPeriod1(i-1) < MAPeriod1(i-2)
Then
Call TWApp.Trade(twSymbol, twDate(i), 1000, twBUY, twClose(i))
ElseIf MAPeriod1(i) < MAPeriod1(i-1) AND MAPeriod1(i-1) >
MAPeriod1(i-2)
Then
Call TWApp.Trade(twSymbol, twDate(i), 1000, twSELL, twClose(i))
End If
End If
Next
End Sub
==============================================
Sub SystemTestEntry()
Call TWApp.Message("Moving Average Crossover Optimized")
Call TWApp.Message(twSymbol & " from " & twStartDate & " to " &
twEndDate)
Dim sFormula
Dim MAPeriod1()
Dim MAValid1()
sFormula = "MOV(c," & V1 & ", s)"
Call TW.CalculateFormula(sFormula, twHigh, twLow, twOpen, twClose, twOI,
twVolume, MAPeriod1, MAValid1)
Dim MAPeriod2()
Dim MAValid2()
sFormula = "MOV(c," & V2 & ", s)"
Call TW.CalculateFormula(sFormula, twHigh, twLow, twOpen, twClose, twOI,
twVolume, MAPeriod2, MAValid2)
For i = 2 to UBound(MAPeriod1, 1)
If MAValid1(i) = 1 AND MAValid2(i) = 1 Then
If MAPeriod1(i) > MAPeriod1(i-1) AND MAPeriod1(i-1) < MAPeriod1(i-2)
Then
Call TWApp.Trade(twSymbol, twDate(i), 1000, twBUY, twClose(i))
ElseIf MAPeriod1(i) < MAPeriod1(i-1) AND MAPeriod1(i-1) >
MAPeriod1(i-2)
Then
Call TWApp.Trade(twSymbol, twDate(i), 1000, twSELL, twClose(i))
End If
End If
Next
End Sub
|