• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-series reference for custom class

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Multi-series reference for custom class

    Hi,

    I have programmed a couple of indicator in the following way:

    I separate indicator calculations in a custom class, and use this class in the indicator that deals with the visual Display of the calculated values from the class.

    In order to do Multi-time Frames, I am seeing that internal data series of the custom classes are always shifted by bar Closes of the Primary series time Frame, since it does not know that it is to be tied to another series.

    Will a back-reference to BarsArray[i] (could be set in OnStartup() ) do the trick or do I have to do something else?

    I know how to back-reference the Price values of the secondary bar series, no Problem, just the internal streams of the class Need to be shifted only on bar closing Events of the secondary bar series, not the Primary bar series.

    Any ideas?

    Thanks,
    Martin

    #2
    Resolved.

    I moved the instantiation of the custom class to OnStartup() where I back-reference with a Dummy Indicator (being an empty indicator having no inputs, no plots and doing nothing) having the BarArrays[n] as parameter.

    Just in case that anyone else will be looking for the same programming concept.

    Cheers,
    Martin

    Comment


      #3
      Originally posted by mstreck View Post
      ...where I back-reference with a Dummy Indicator (being an empty indicator having no inputs, no plots and doing nothing) having the BarArrays[n] as parameter.
      What do you mean by back-referencing with a dummy indicator? Can you give an example from your OnStartUp?

      Thanks

      Comment


        #4
        So here is an example.

        I write my indicators with a custom class where I put all Price calculations. The indicator uses the custom class and uses its properties to Display them on a Chart. That way I can re-use the custom class in an easy way for strategies making sure that the indicator and strategy are consistent.

        In the custom class I define a private Indicator obj, which will allow me to reference Price series not as Close[0], but as obj.Close[0], for example.

        For a single-Instrument / single-time Frame, you can have the indicator code create an instance of the custom class using "this" in the constructor for the "Indicator obj". This can be put into Initialize(), no problem.

        BUT:

        In case of a multi-series indicator where the custom class uses DataSeries or IntSeries etc you Need to make sure that they are shifted on the granularity of the price series the custom class is attached to. That was my problem.

        For that case, you have to move the instantiation of the custom class from Initialize() to OnStartup(), where you replace "this" by "DummyIndicator(BarsArray[i])", where DummyIndicator is an empty indicator, i.e. it does nothing in any of its methods, and where i is the index of the bar series to attach the custom class to.

        If you Need an example, I can see to make a simple one, if it is of real interest.

        Cheers,
        Martin
        Last edited by mstreck; 03-05-2015, 09:37 AM.

        Comment


          #5
          Thanks Martin, your solution to the problem I experienced myself makes perfect sense now - after all by providing dummy indicator with separated BarsArray you make it clear to the class which bars the DataSeries should be anchored to!

          Comment


            #6
            Great. Please note I corrected last post in that the "private Indicator obj" is part of the custom class, not the indicator as I originally wrote.

            Cheers,
            Martin

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rickyblah12, Today, 01:01 PM
            0 responses
            7 views
            0 likes
            Last Post rickyblah12  
            Started by dadarara, Today, 12:18 PM
            0 responses
            8 views
            0 likes
            Last Post dadarara  
            Started by joemiller, Today, 07:33 AM
            0 responses
            8 views
            0 likes
            Last Post joemiller  
            Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
            7 responses
            38 views
            0 likes
            Last Post DaveS
            by DaveS
             
            Started by claxxical, Yesterday, 10:00 PM
            0 responses
            12 views
            0 likes
            Last Post claxxical  
            Working...
            X