Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Using indicator within indicator

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

    Using indicator within indicator

    I am trying to develop an indicator that uses the data from another indicator, for example SMA
    but I want the SMA to be calculate using new data that I am creating during running,
    for that, inside OnBarUpdate Im trying to insert the line:
    SeriesA[0] = SMA((SeriesB+ SeriesC) * 3, 6)[0]
    with no success, how can I make operations on data series I have created and how can I use it as input for the SMA function ?

    Thanks

    #2
    Using you're example,
    you would need to create a fully self-contained SeriesD,

    SeriesD[0] = (SeriesB[0] + SeriesC[0]) * 3;

    SeriesA[0] = SMA(SeriesD, 6)[0];

    Make sense?

    Comment


      #3
      EDIT:
      This is the comment by OP before post was deleted:
      "Yes, Thanks And how can I get the bollinger upper and lower bands
      values if I would like to use it within my indicator ? Thanks"

      I've resurrected his question here, since it helps to explain my post.
      (Besides, it's a fairly good question, and equally good response. )

      -=o=-

      Since you're into NinjaScript, let's go over how to find the answer.

      How do you 'think' you're supposed to do it?
      (I'm not being mean, stay with me)

      That is, your 'thinking' is already there -- almost.

      Instead of just giving you the fish, I'll try to teach you how to fish.

      Ready?

      -=o=-

      Whenever you have a question (like the above) about accessing the
      public data pieces of a specific indicator, go to the source code of
      that indicator, in this case @Bollinger.cs -- and first thing to do is
      scroll down to find the 'Properties' section.

      See 1st attached screenshot.

      Look for the names of the public properties, these are the names that
      you can use when accessing that indicator.

      That's tip number 1.

      -=o=-

      But how do you call that indicator?

      Your thinking with using SMA was spot-on, but here's how you know
      for sure -- Bollinger is a little harder, because calling it takes 2 arguments.

      How do I know that?

      Scroll past the Properties in @Bollinger.cs -- you're looking for the
      'NinjaScript generated code' section.

      Don't scroll too far.
      The first method you see is how you call that indicator.

      See 2nd attached screenshot.

      That's tip number 2.

      -=o=-

      Let's put both tips together.

      So, now you know, to call Bollinger, you'll provide two arguments, the
      StdDev and Period, something like this,

      Bollinger(2, 14)

      and to get the upper and lower values, you found these were available
      as public properties, and since they are data series, you access those
      next, like this,

      Bollinger(2, 14).Upper
      Bollinger(2, 14).Lower

      Now the above returns the whole Series<double>, but you don't usually
      want the whole enchilada, you just want a piece, the last piece.

      So, to get the value of the most recently closed bar, you use a BarsAgo
      index of '0' at the end, just like you did with SMA, like this,

      Bollinger(2, 14).Upper[0]
      Bollinger(2, 14).Lower[0]

      That's it!

      Make sense?
      Attached Files
      Last edited by bltdavid; 02-19-2023, 07:45 PM. Reason: Apparently typing #1 and #2 get expanded. Had to retype as 'number '1 and 'number 2'.

      Comment


        #4
        Hello yaniv,

        THanks for your note.

        bltdavid is correct.

        You could create a Series<double> variable, such as SeriesD, and assign (SeriesB[0] + SeriesC[0]) * 3 to that SeriesD variable. Then, you could use that SeriesD variable when calling SMA(ISeries<double> input, int period)[int barsAgo].

        ​For example, SeriesA[0] = SMA(SeriesD, 6)[0];.

        See the help guide documentation below for more information.

        Series<T>: https://ninjatrader.com/support/help...t8/seriest.htm
        SMA(): https://ninjatrader.com/support/help...simple_sma.htm

        Please let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by giulyko00, 04-24-2024, 12:03 PM
        9 responses
        43 views
        0 likes
        Last Post giulyko00  
        Started by memonic, Yesterday, 01:23 PM
        2 responses
        24 views
        0 likes
        Last Post memonic
        by memonic
         
        Started by merc410, Today, 03:41 AM
        2 responses
        15 views
        0 likes
        Last Post merc410
        by merc410
         
        Started by sugalt, 04-30-2024, 04:02 AM
        2 responses
        13 views
        0 likes
        Last Post sugalt
        by sugalt
         
        Started by Ndakotan1313, 03-14-2024, 05:02 PM
        2 responses
        64 views
        0 likes
        Last Post blaise_code  
        Working...
        X