• 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

  • mstreck
    replied
    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

    Leave a comment:


  • gregid
    replied
    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!

    Leave a comment:


  • mstreck
    replied
    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.

    Leave a comment:


  • gregid
    replied
    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

    Leave a comment:


  • mstreck
    replied
    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

    Leave a comment:


  • mstreck
    started a topic Multi-series reference for custom class

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by habibalex, Today, 09:45 AM
1 response
3 views
0 likes
Last Post NinjaTrader_Tabor  
Started by peterslane1, Today, 09:47 AM
0 responses
6 views
0 likes
Last Post peterslane1  
Started by mtamaku, Today, 09:34 AM
0 responses
6 views
0 likes
Last Post mtamaku
by mtamaku
 
Started by datahogg, Today, 08:48 AM
1 response
7 views
0 likes
Last Post NinjaTrader_Kate  
Started by Newtrader101, 11-02-2019, 06:36 PM
4 responses
405 views
1 like
Last Post datahogg  
Working...
X