Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator input series

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

    Indicator input series

    Hi.
    When I want to have daily SMA indicator displayed over i.e. 10-min chart, then we have to add additional 1-day dataseries on chart, and then choose that dataseries as "input" for SMA indicator.

    However, I am trying to achieve the following (to avoid adding additional subchart datafeed on chart, to avoid distortion):

    1) Create indicator (so far this code: https://pastebin.com/KSRNRn5f )

    2) Adding SMA on chart, and in "INPUT SERIES" , referring to that XYZ indicator.

    3) choosing DAILY feed ( https://i.imgur.com/D6uvOhw.png ) so it will be set as the internal dataseries (with AddDataSeries function ) inside XYZ indicator, so it returned daily data.

    However, the XYZ indicator's Value indexing is still resolved to 10-minute timeframe, thus, Value[0] refer to current 10min bar value, and Value[1] refer to previous 10min bar value. So, I couldnt achieve the result. So, any help will be appreciated, to make XYZ indicator to resolve it's Value to i.e Daily timeframe (thus, the SMA function had a "feed" of daily data).

    #2
    Hello ttodua,

    Thank you for the post.

    The way you have used AddDataSeries in this script is not correct, it cannot be based on runtime variables like user input. That will not work in all use cases so it should be avoided. You would need to hard code the secondary series that you wanted to use.

    Code:
    AddDataSeries(BarsPeriodType.Day, 1);

    However, the XYZ indicator's Value indexing is still resolved to 10-minute timeframe, thus, Value[0] refer to current 10min bar value, and Value[1] refer to previous 10min bar value. So, I couldnt achieve the result. So, any help will be appreciated, to make XYZ indicator to resolve it's Value to i.e Daily timeframe (thus, the SMA function had a "feed" of daily data).
    Right, if you apply the indicator to a 10 minute timeframe it will have 10 minute slots for the plot. You would not be able to plot something in a different way so the BarsAgo will always represent your primary series when referring to a plot.

    By plotting the daily value Value[0] = Closes[1][0]; you should see a stairs like plot where a constant value is plotted for a period of time until a new constant value is plotted. The lower timeframe will be called many times and the last daily close value will stay the same so we are just re plotting the same value over and over.

    You could create a daily SMA and replot it by using AddDataSeries and the passing the BarsArray[1] to the SMA:

    Code:
    Value[0] = SMA(BarsArray[1], 12)[0];


    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse, Nice to hear reply from you! thanks.

      however, i feel a bit of need to hear a bit more from you

      Specifically, in the original post, i've tried to explain what is my goal. it's simple - to avoid adding any subchart, instead, creating a "bridge" indicator to do the job.

      when you say i.e
      Value[0] = SMA(BarsArray[1], 12)[0];
      actually, Value[1] and Value[2] and etc.. will still all have almost same DAILY value (as Value[1] will not be SMA(...)[1]. instead it will be still same day's SMA'[0] ).

      I dont know if i express it easily understandable, but i have been searching a way to achieve "having indicator" on primary chart, which is based on other TF datafeed (and this needed to be done without adding separate subgraph). The reason I want to avoid adding sub-chart, is that it makes the primary chart-bars to scatter and it's visually unpleasant to work on such chart : https://i.imgur.com/rD8xKo4.png

      So, i was trying to make a XYZ indicator, which is based on other-timeframe datafeed, and thus, i could add EMA (or whatever) indicator on chart, and its Input "Data series" I could select XYZ indicator (which, on its hand, should be based on any AddDateSeries resolution).

      Thus for example, if i am on 10min chart, and added EMA (which's INPUT"DATA SERIES" i would have selected XYZ indicator based on 1-day data), then EMA[0] would have ploted current day value, EMA[1] previous day and so on... But at this moment, EMA[0], EMA[1], etc... all resolve to the related 10-minute slot. So, basically, I want to achieve that I could have indicator on primary chart, which is based on other TF, but without adding chart-subgraph. [Yah, if there is any way to add chart subgraph without making primary chart to be forced to align with time-sync, then Huh, SURE, THAT WILL BE SOLUTION ! ]

      If you can't udnerstand what I say, then ok, don't worry, and take your time..
      thanks..
      Last edited by ttodua; 02-03-2021, 03:58 PM.

      Comment


        #4
        Hello


        but i have been searching a way to achieve "having indicator" on primary chart, which is based on other TF datafeed (and this needed to be done without adding separate subgraph).
        This is what I provided an example of. Calling an indicator in code and passing a specific BarsArray would avoid adding it to the chart and allow you to replot its data how you wanted. Your indicator could be applied to the primary panel, if the price is different you can use overlay scaling.


        So, i was trying to make a XYZ indicator, which is based on other-timeframe datafeed, and thus, i could add EMA (or whatever) indicator on chart, and its Input "Data series" I could select XYZ indicator (which, on its hand, should be based on any AddDateSeries resolution).
        You could do that to re plot your indicator using it as input for the EMA. This is essentially what I provided as an example in code but you are doing it manually by inputting your indicator into the EMA on the chart. In that situation you could do Value[0] = Closes[1][0]; to pass the secondary data to the EMA when you input the indicator.

        Please let me know if I may be of additional assistance.



        Comment


          #5
          thanks, I am editing the indicator. in the meantime, can you tell, what is difference between adding by hardcoded way:
          AddDataSeries(BarsPeriodType.Day, 1);

          and with variable:
          AddDataSeries(myBpType.Day, myPeriod);

          How C# makes that to matter, as it should matter in any way, as everything happens during runtime ?

          Comment


            #6
            Hello ttodua,

            The difference between those two uses would not be a C# difference but how the platform expects the data to be provided to the method. Using variables is specifically documented as it will not work in all areas of the platform, variables cannot be used like that in all areas with AddDataSeries reliably so you should not use that type of code.

            The only case where that may work as expected would be if you always apply the script fresh and don't may use of any of the NinjaScript reload features or changing data series features. For example applied to a chart, changing the data series it may fail to work as expected. You would have to remove the script and re apply it for any change you make on the chart to make sure it loads the right data. That is not reliable as just specifying the series in code and knowing it works as you expected.

            Please let me know if I may be of further assistance.

            Comment


              #7
              Hi Jesse.
              Any possible update with regard to making "AddDataSeries(myBpType, myBpLength);" a reliable approach in Configure state, while those variables are being set with inputs (in SetDefaults state)?
              I ask that because, many clients are trying to use indicators with their desired chosen TF, and I **have to avoid** just hardcoded values in AddDataSeries. Please, if possible, send Dev-Team a vote to make fix so that approach will not be "inreliable" anymore.

              Comment


                #8
                Hello ttodua,

                unfortunately we cannot check the status of feature requests, this item has been received by development. If it is added in the future the documentation will be updated and this will be noted in the change logs. Currently it is documented to avoid so that is all I can suggest to do.



                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X