Profile Picture

Creating Custom Indicators From Other Indicators or HELP PLEASE

Posted By blousetrader 7 Years Ago

Creating Custom Indicators From Other Indicators or HELP PLEASE

Message
Posted Friday March 19 2010
I've created a system which has the code below - while it works its very messy and I'd really like to create the VarMASeries as an indicator plugin. I'm still struggling
with creating custom indicators and this one is definatley beyond me at the minute - any help would be greatly appreciated.



   Private Constant100 As ConstantSeries
   Private Constant2 As ConstantSeries
   Private Constant1 As ConstantSeries
   Private Constant02 As ConstantSeries
   Private Constant0 As ConstantSeries
   Private Constant20 As ConstantSeries
   Private Constant80 As ConstantSeries

   Private PlusDI As DIPlus
   Private MinusDI As DIMinus
   
   Private DIDifInput As SubtractSeries
   Private DIDif As AbsoluteValue
   Private DISum As AddSeries
   
   Private ADXFinalVarInp As DivideSeries
   Private ADXFinalVar As WildersSmoothing
   Private ADXFinal As MultiplySeries
   Private ADXFinalShift As Shift
   Private ADXRAdd As AddSeries
   Private ADXRCustom As DivideSeries

   
   'Private EMAIndex As UserSeries
   Private HighVal As Highest
   Private LowVal As Lowest
   Private Diff As SubtractSeries
   Private DiffLow As SubtractSeries
   Private DiffDiv As DivideSeries
   Private MyConst As UserSeries
   Private SMASeries As UserSeries
   Private VarSeries As UserSeries

'   
Private VarMASeries As UserSeries
   Private MA22 As UserSeries
   Private MA100 As UserSeries
   
   'Private VarMA As VariableMA
   
   Private StochM As StochasticOscillator
   Private StochS As StochasticOscillatorD
   
   Public Overloads Overrides Sub Startup()
      ' Perform initialization here
      Dim ADXPr As Integer = 8
      
      Constant100 = New ConstantSeries(100)
      Constant2 = New ConstantSeries(2)
      Constant1 = New ConstantSeries(1)
      Constant02 = New ConstantSeries(0.4)
      Constant0 = New ConstantSeries(0)
      

      PlusDI = New DIPlus(ADXPr)
      MinusDI = New DIMinus(ADXPr)
      
      DIDifInput = New SubtractSeries
      DIDifInput.SetInputs(PlusDI,MinusDI)
      DIDif = New AbsoluteValue
      DIDif.SetInputs(DIDifInput)
      DISum = New AddSeries
      DISum.SetInputs(PlusDI,MinusDI)
      
      ADXFinalVarInp = New DivideSeries
      ADXFinalVarInp.SetInputs(DIDif,DISum)
      ADXFInalVar = New WildersSmoothing(ADXPr,ADXFinalVarInp)
      ADXFinal = New MultiplySeries
      ADXFinalShift = New Shift(7)
      ADXFinalShift.SetInputs(ADXFinal)
      ADXFinal.SetInputs(Constant100,ADXFinalVar)
      
      ADXRAdd = New AddSeries
      ADXRAdd.SetInputs(ADXFinal,ADXFinalShift)
      ADXRCustom = New DivideSeries
      ADXRCustom.SetInputs(ADXRAdd,Constant2)
      

'      
      'EMAIndex = New UserSeries
    'HighVal = New Highest(ADXPr,_ADX)
    'LowVal = New Lowest(ADXPr,_ADX)
      HighVal = New Highest(ADXPr,ADXRCustom)
    LowVal = New Lowest(ADXPr,ADXRCustom)
    Diff = New SubtractSeries
      Diff.SetInputs(HighVal,LowVal)
   
'      VarMA = New VariableMA(2,ADXRCustom)
'      VarMA.ChartSettings.Color = Color.Black
'      VarMA.ChartSettings.LineSize = 2
      
      DiffLow = New SubtractSeries
      DiffLow.SetInputs(ADXRCustom,LowVal)
      DiffDiv = New DivideSeries
      DiffDiv.SetInputs(DiffLow,Diff)
      
      MyConst = New UserSeries
      SMASeries = New UserSeries
      VarMASeries = New UserSeries
      VarSeries = New UserSeries
      VarMASeries.ChartSettings.Color = Color.Black
      VarMASeries.ChartSettings.LineSize = 2

      MA22 = New UserSeries
      MA22.ChartSettings.Color = Color.Green
      MA22.ChartSettings.LineSize = 2
      
      MA100 = New UserSeries
      MA100.ChartSettings.Color = Color.Magenta
      MA100.ChartSettings.LineSize = 2

'VarMA = New VariableMA(2,
      
HighVal.ChartSettings.ShowInChart = False
LowVal.ChartSettings.ShowInChart = False
      MinusDI.ChartSettings.ShowInChart = False
    PlusDI.ChartSettings.ShowInChart = False
    DIDifInput.ChartSettings.ShowInChart = False
      DIDif.ChartSettings.ShowInChart = False
      DISum.ChartSettings.ShowInChart = False
      ADXFinalVarInp.ChartSettings.ShowInChart = False
      ADXFinalVar.ChartSettings.ShowInChart = False
      ADXFinal.ChartSettings.ShowInChart = False
      ADXFinalShift.ChartSettings.ShowInChart = False
      ADXRAdd.ChartSettings.ShowInChart = False
      ADXRCustom.ChartSettings.ShowInChart = False
      DiffLow.ChartSettings.ShowInChart = False
      DiffDiv.ChartSettings.ShowInChart = False
      MyConst.ChartSettings.ShowInChart = False
      Diff.ChartSettings.ShowInChart = False
      VarSeries.ChartSettings.ShowInChart = False
      'VarMASeries.ChartSettings.ShowInChart = False
      SMASeries.ChartSettings.ShowInChart = False
      
      
      
      
      StochM = New StochasticOscillator(6,3)
      StochS = New StochasticOscillatorD(6,3,3)
      Constant20 = New ConstantSeries(20)
      Constant20.ChartSettings.ChartPaneName = "SOPane"
      Constant20.ChartSettings.ShowInChart = True
      Constant20.ChartSettings.LineType = 1
      Constant80 = New ConstantSeries(80)
      Constant80.ChartSettings.ChartPaneName = "SOPane"
      Constant80.ChartSettings.ShowInChart = True
      Constant80.ChartSettings.LineType = 1
      


   End Sub

   Public Overloads Overrides Sub NewBar()
      ' Put your trading code here
      Dim ADXType As Integer = 2 '2 is EMA, 0 is Simple MA
      Dim VarMAPr As Integer = 4
      Dim ADXPr As Integer = 8
      Dim EMAIndex As Double = 0.4
      Dim VarMAPeriod2 As Integer = 2
      Dim VarMAPeriod22 As Integer = 22
      Dim VarMAPeriod100 As Integer = 100
      
      Dim OpenTrade As Boolean
      
      
      'Build UserSeries here

      MyConst.Current = IIf(Diff.Current > Constant0.Current,DiffDiv.Current,Constant02.Current)
      MyConst.Current = IIf(MyConst.Current > Constant02.Current,Constant02.Current,MyConst.Current)

If Bars.Count < ADXpr + (ADXPr*1.5) Then
VarSeries.setvalue(0,Close.Current)
Else
       VarSeries.setvalue(0,((1-MyConst.Current) * VarSeries.LookBack(1)) + (MyConst.Current * Close.Current))
      End If
      
   
      If bars.Count = 1 Then
         SMASeries.SetValue(0,VarSeries.current)
      Else   
       SMASeries.SetValue(0,(VarSeries.Current + VarSeries.LookBack(1))/2)
      End If
'systemdata.Output.add(OutputSeverityLevel.Informational,bars.Count,Me.Symbol,SMASeries.Current)
      
      
      'EMA(current) = ( (Price(current) - EMA(prev) ) x Multiplier) + EMA(prev)
'For a percentage-based EMA, "Multiplier" Is equal To the EMA's specified percentage. For a period-based EMA, "Multiplier" is equal to 2 / (1 + N) where N is the specified number of periods.
      
      '2 period EMA of SMASeries
      If bars.Count <= ADXpr + (ADXPr*1.5) Then
         VarMASeries.Setvalue(0,SMASeries.Current)
         MA22.Setvalue(0,SMASeries.Current)
         MA100.Setvalue(0,SMASeries.Current)
      Else   
         VarMASeries.SetValue(0,(SMASeries.Current - VarMASeries.LookBack(1))*(2/(1+VarMAPeriod2)) + VarMASeries.LookBack(1))
         MA22.SetValue(0,(SMASeries.Current - MA22.LookBack(1))*(2/(1+VarMAPeriod22)) + MA22.LookBack(1))
         MA100.SetValue(0,(SMASeries.Current - MA100.LookBack(1))*(2/(1+VarMAPeriod100)) + MA100.LookBack(1))
      End If
phg
Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)
Posted Saturday March 20 2010
I am overwhelmed by the detail. Is there a more concise plain english overview of what this is trying to do? Thanks. -Pete

-Pete

See also Yahoo group about applying RE.

Posted Saturday March 20 2010
Its an implementation of the Rainbow Fantail (without all the extra moving averages). I'm really not expecting anyone to do this
for me, just looking for a few pointers. What I can't work out how to do is use the standard indicatros within my own
custom indicators - even looking at the example in the Creating Custom Indicators post hasn't shed any light on it for me.
phg
Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)Supreme Being (44,783 reputation)
Posted Saturday March 20 2010
Sorry, I don't know how to help. However, I googled on "rainbow fantail indicator" and this turns up other implementations. I don't know whether one of those would suggest something.

-Pete

See also Yahoo group about applying RE.



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems