WILSON RELATIVE PRICE CHANNEL PARA VISUAL CHART 5. 'กก Parameters Dim ChannelPeriod As Integer '34 Dim Smoothing As Integer '1 Dim OverBougth As Double '70 Dim OverSold As Double '30 Dim UpperNeutralZone As Double '55 Dim LowerNeutralZone As Double '45 'Parameters !! Dim rsidata As DataIdentifier Dim avexpdata As DataIdentifier Dim comptype As CompresionRange Option Explicit Public APP As OscUserApp Implements Indicator Public Sub Indicator_OnInitCalculate() With APP rsidata = .GII(RSI, Data, ChannelPeriod, 70, 30) avexpdata = .GII(AvExponential, Data, Smoothing, PriceClose) comptype = .GetSymbolInfo(SbiCompresion) .SetLineName 1, "Upper Neutral Zone" .SetLineName 2, "Lower Neutral Zone" .SetLineName 3, "Upper Channel" .SetLineName 4, "Lower Channel" .SetLineName 5, "Upper Neutral Line" .SetLineName 6, "Lower Neutral Line" End With End Sub Public Sub Indicator_OnCalculateBar(ByVal Bar As Long) With APP Dim arr_ob() As Double Dim arr_os() As Double Dim arr_nzu() As Double Dim arr_nzl() As Double ReDim arr_ob(Smoothing) ReDim arr_os(Smoothing) ReDim arr_nzu(Smoothing) ReDim arr_nzl(Smoothing) Dim i As Integer For i = 0 To Smoothing - 1 arr_ob(i) = .GIV(rsidata, i) - OverBougth arr_os(i) = .GIV(rsidata, i) - OverSold arr_nzu(i) = .GIV(rsidata, i) - UpperNeutralZone arr_nzl(i) = .GIV(rsidata, i) - LowerNeutralZone Next i Dim ob As Double Dim os As Double Dim nzu As Double Dim nzl As Double ob = CalculoMExp(NullValue, Smoothing, arr_ob, False) os = CalculoMExp(NullValue, Smoothing, arr_os, False) nzu = CalculoMExp(NullValue, Smoothing, arr_nzu, False) nzl = CalculoMExp(NullValue, Smoothing, arr_nzl, False) Dim tamamax As Double Dim avexpact As Double If (comptype <= crMinutos) Then avexpact = .GIV(avexpdata) tamamax = .GetHighest(Data, PriceHigh, (ChannelPeriod * 100)) - .GetLowest(Data, PriceLow, (ChannelPeriod * 100)) Else avexpact = .Close() tamamax = .Close() End If Dim pob As Double Dim pos As Double Dim pnzu As Double Dim pnzl As Double pob = avexpact - (tamamax * (ob / 100)) pos = avexpact - (tamamax * (os / 100)) pnzu = avexpact - (tamamax * (nzu / 100)) pnzl = avexpact - (tamamax * (nzl / 100)) .SetIndicatorValue pnzu, 1 .SetIndicatorValue pnzl, 2 .SetIndicatorValue pob, 3 .SetIndicatorValue pos, 4 .SetIndicatorValue pnzu, 5 .SetIndicatorValue pnzl, 6 .SetBarProperties 0, 1, RGB(204, 255, 204), 1, lsSolid, irHistogram .SetBarProperties 0, 2, RGB(204, 153, 255), 1, lsSolid, irHistogram .SetBarProperties 0, 3, RGB(204, 255, 204), 2, lsSolid, irLineal .SetBarProperties 0, 4, RGB(204, 153, 255), 2, lsSolid, irLineal .SetBarProperties 0, 5, RGB(204, 255, 204), 2, lsSolid, irLineal .SetBarProperties 0, 6, RGB(204, 153, 255), 2, lsSolid, irLineal .SetHistogramBand 1, 3 .SetHistogramBand 2, 4 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 Private Function CalculoMExp(MEdiaANT As Double, PeriodoMME As Integer, Precios() As Double, EsMedSig As Boolean) As Double With APP Dim i As Long: Dim K As Double Dim PrecioCierre As Double Dim EMA_Hoy As Double Dim EMA_Ayer As Double Dim SumaCierres As Double Dim x As Integer If MEdiaANT <> NullValue Then EMA_Ayer = MEdiaANT K = 2 / (PeriodoMME + 1) PrecioCierre = Precios(0) EMA_Hoy = PrecioCierre * K + EMA_Ayer * (1 - K) Else If EsMedSig Then x = 1 For i = PeriodoMME - 1 To x Step -1 PrecioCierre = Precios(i) SumaCierres = SumaCierres + PrecioCierre Next i EMA_Hoy = SumaCierres / (PeriodoMME - x) End If CalculoMExp = EMA_Hoy End With End Function