Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy reading values from an specific indicator applied to chart

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

    strategy reading values from an specific indicator applied to chart

    Hi,

    i want to do the following:

    I have an indicator which allows me to fill a list of values (Bar Numbers and Prices) by mouse events, the values are entered manually !

    What I want now is reading the list of the indicators values which were entered manually via on bar update by the strategy when I apply a strategy to the chart, and calculate a historical performance.

    the code in the strategy on bar update method should look something like:

    if list (indicator) contains barnumber enter long or short (depending on other details)

    so that the strategy performance can be calculated historically for the manually entered data.

    my specific problem is i do not know how i can access the manually populated list inside the indicator code.

    is this possible? if not, is there a other way to do that?
    Last edited by keepsimple; 08-25-2016, 05:21 AM.

    #2
    Hello,

    Thank you for the question.

    A Strategy would need to Add an indicator in order to be directly associated with that indicator or to "Host" the indicator.

    Has the strategy already been applied at this point and has added the indicator? Or are you asking to have a strategy read an indicator that was already applied to a chart and configured by the user?



    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse,

      thats exactly the problem I am facing, I need to configure the data first and after configuration have the strategy run over the configured data. if I host the indicator or store the data in the strategy itself, configuration cannot be done, before running onbarupdate, so stated otherwise i am looking for a way to configure data and after that, run the strategy on the data. To answer your question the strategy should read indicator data already applied. Maybe there is another or better way, which i whould appreciate too, just need to get that working.

      regards

      Comment


        #4
        P.S. What would be an option too, I think, whould be forcing the strategy to recalculate historically, but i dont know, if this is possible.

        Comment


          #5
          Hello,

          Thank you for clearing that up.

          You could probably go a few ways with this being that NT8 you have more exposed items like the charts Indicator collection.

          As I see it you could use either a save/load type of system:
          1. Apply indicator and click/setup list etc.
          2. Have indicator save the list to file
          3. Apply strategy which includes a input to specify the Filename it should load.


          If the indicator only gets configured before the strategy starts and not after this would likely work.

          If the indicator needs to be updated in realtime and the strategy needs to read that, you could look into other ways of doing this by accessing the charts Indicator collection. There is not a huge amount of documentation around this topic, but you could in essence access the instances of indicators from the ChartControl which you could get a Property from.



          Please note in the sample it casts:
          Code:
          NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator
          in the foreach loop, this would entail only base properties will be accessible (Calculate, IsOverlay etc.. ). To access your custom indicators properties, you would need to locate the indicator with its type or:

          Code:
          if(indicator.GetType() == typeof(MyCustomIndicatorName))
          {
              MyCustomIndicatorName indicatorInstance = indicator as MyCustomIndicatorName;
          }
          A cast to the type of indicator that contains the list would be needed, you could then access any public properties of that type from its instance.

          I look forward to being of further assistance.

          Comment


            #6
            Thanks Jesse,

            this looks very good, i will have a look at both options and post back, if I have additional questions.

            Comment


              #7
              Hi Jesse,

              i think going with the indicator collection whould work, but could you give me a little more heads up, on how to do that, please. e.g. where do i place the code, what do i need, how do i access the property, a example whould be nice mentioning the methods and places, where to place the code.

              thanks in advance and regards

              Comment


                #8
                Hello,

                If you review the help guide section this is listed in:

                NinjaScript > Language Reference > Common > Charts > ChartControl >

                This would entail this is specific to the ChartControl, so the sample could be used bascially anywhere in a Indicator or other script that has a ChartControl object in any states where ChartControl is not null.

                The sample would only need slight modification because it is shown in OnRender. I have combined the previous code into the existing sample below. You could run this from OnBarUpdate as an example:

                Code:
                if(ChartControl != null)
                {
                	foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in ChartControl.Indicators)
                	  {
                		  if(indicator.GetType() == typeof(SMA))
                		  {
                			  SMA mySMA = indicator as SMA;
                			  if(mySMA != null)
                			  {
                				 Print("SMA Period: " + mySMA.Period);  
                			  }
                		  }
                	  }
                }
                Where SMA is listed, that would be your custom indicator and where Period is used would be the custom lists property.

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

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                660 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                375 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                110 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                579 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X