Bonjour,
Il va vous falloir créer 2 indicateurs dont le codes suivent. Le premier fichier concerne la régression linéaire, le deuxième est celui des bandes Mogalef.
'1er fichier "SOURCEREG"
'¡¡ Parameters
'Parameters !!
Dim dato_p#, filtre#
Option Explicit
Public APP As OscUserApp
Implements Indicator
Public Sub Indicator_OnInitCalculate()
With APP
dato_p = 0
.StartBar = 0
End With
End Sub
Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
dato_p = (.Open + .High + .Low + 2 * .Close) / 5
.SetIndicatorValue dato_p
End With
End Sub
Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
'¡¡ Parameters initialization
'Parameters initialization !!
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
___________________________________________...
'2eme fichier
'¡¡ Parameters
Dim x As Double '3
Dim y As Double '7
'Parameters !!
Dim ant_bar As Double
Dim dato_p#, filtre#, p#, indicador#, desv_data#, desv#, media_desv#
Dim vh#, vhvb#, vb#, vh_ant#, vb_ant#, desv_ant#, filtre_triang#, ind_triang#
Dim E_Type As DataIdentifier
Option Explicit
Public APP As OscUserApp
Implements Indicator
Public Sub Indicator_OnInitCalculate()
With APP
dato_p = .GetIndicatorIdentifier(SOURCEREG, Data)
filtre_triang = .GetIndicatorIdentifier(LINEARREGRESION, dato_p, x, PriceClose)
E_Type = .GetIndicatorIdentifier(StandardDev, filtre_triang, y, PriceClose)
filtre = 0: indicador = 0: desv = 0: media_desv = 0: vh = 0: vb = 0: vh_ant = 0: vb_ant = 0: desv_ant = 0
.StartBar = 0
End With
End Sub
Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
Dim i%, aux#, ind_aux#
If ant_bar <> Bar Then
ant_bar = Bar
vh_ant = vh
vb_ant = vb
desv_ant = desv
End If
p = .GetIndicatorValue(dato_p, 0, 1)
indicador = .GetIndicatorValue(filtre_triang, 0, 1)
desv = .GetIndicatorValue(E_Type, 0, 1)
vh = indicador + (desv * 2)
vb = indicador - (desv * 2)
If indicador < vh_ant And indicador > vb_ant Then
If vh_ant <> 0 And vb_ant <> 0 And desv_ant <> 0 Then
vh = vh_ant: vb = vb_ant: desv = desv_ant
End If
End If
vhvb = (vh + vb) / 2
.SetIndicatorValue vh, 1
.SetIndicatorValue vb, 2
.SetIndicatorValue vhvb, 3
End With
End Sub
Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
'¡¡ Parameters initialization
x = ParamList(1)
y = ParamList(2)
'Parameters initialization !!
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
Il va vous falloir créer 2 indicateurs dont le codes suivent. Le premier fichier concerne la régression linéaire, le deuxième est celui des bandes Mogalef.
'1er fichier "SOURCEREG"
'¡¡ Parameters
'Parameters !!
Dim dato_p#, filtre#
Option Explicit
Public APP As OscUserApp
Implements Indicator
Public Sub Indicator_OnInitCalculate()
With APP
dato_p = 0
.StartBar = 0
End With
End Sub
Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
dato_p = (.Open + .High + .Low + 2 * .Close) / 5
.SetIndicatorValue dato_p
End With
End Sub
Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
'¡¡ Parameters initialization
'Parameters initialization !!
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
___________________________________________...
'2eme fichier
'¡¡ Parameters
Dim x As Double '3
Dim y As Double '7
'Parameters !!
Dim ant_bar As Double
Dim dato_p#, filtre#, p#, indicador#, desv_data#, desv#, media_desv#
Dim vh#, vhvb#, vb#, vh_ant#, vb_ant#, desv_ant#, filtre_triang#, ind_triang#
Dim E_Type As DataIdentifier
Option Explicit
Public APP As OscUserApp
Implements Indicator
Public Sub Indicator_OnInitCalculate()
With APP
dato_p = .GetIndicatorIdentifier(SOURCEREG, Data)
filtre_triang = .GetIndicatorIdentifier(LINEARREGRESION, dato_p, x, PriceClose)
E_Type = .GetIndicatorIdentifier(StandardDev, filtre_triang, y, PriceClose)
filtre = 0: indicador = 0: desv = 0: media_desv = 0: vh = 0: vb = 0: vh_ant = 0: vb_ant = 0: desv_ant = 0
.StartBar = 0
End With
End Sub
Public Sub Indicator_OnCalculateBar(ByVal Bar As Long)
With APP
Dim i%, aux#, ind_aux#
If ant_bar <> Bar Then
ant_bar = Bar
vh_ant = vh
vb_ant = vb
desv_ant = desv
End If
p = .GetIndicatorValue(dato_p, 0, 1)
indicador = .GetIndicatorValue(filtre_triang, 0, 1)
desv = .GetIndicatorValue(E_Type, 0, 1)
vh = indicador + (desv * 2)
vb = indicador - (desv * 2)
If indicador < vh_ant And indicador > vb_ant Then
If vh_ant <> 0 And vb_ant <> 0 And desv_ant <> 0 Then
vh = vh_ant: vb = vb_ant: desv = desv_ant
End If
End If
vhvb = (vh + vb) / 2
.SetIndicatorValue vh, 1
.SetIndicatorValue vb, 2
.SetIndicatorValue vhvb, 3
End With
End Sub
Public Sub Indicator_OnSetParameters(ParamArray ParamList() As Variant)
'¡¡ Parameters initialization
x = ParamList(1)
y = ParamList(2)
'Parameters initialization !!
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
Commentaire