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

Indicator in indicator

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

    Indicator in indicator

    Hello.
    I have question.
    It's possible to set values or use functions of included indicator?
    Like this: includedIndicator.value = 3; includedIndicator.someFunction(value);

    #2
    Hello nordseven,

    Thank you for your note.

    So I may best answer your question could you please provide additional information on what you are trying to do, perhaps with an example?

    For example, are you trying to set the value of the output of an SMA in an Indicator, to something else?

    Could you provide an example of a function in an indicator that you'd like to use outside the script?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      INDICATOR 1
      *******************
      Code:
      public class InsideIndicator : Indicator
      	{
      
              private int abc;
      
      		protected override void OnStateChange()
      		{
      			if (State == State.SetDefaults)
      			{
      				abc	                                                                = 1;
      				BarsRequiredToPlot					= 1;
      				AddPlot(Brushes.Blue, "ThePlot");		
      			}
      			else if (State == State.Configure)
      			{
      			}
      		}
      
      		protected override void OnBarUpdate()
      		{
      			//Add your custom indicator logic here.
      			Value[0] = abc * multiplyAbc;
      		}
      
      		#region Properties
      		[Range(1, int.MaxValue)]
      		[NinjaScriptProperty]
      		[Display(Name="multiplyAbc", Order=1, GroupName="Parameters")]
      		public int multiplyAbc
      		{ get; set; }
      		#endregion
      
                      public int myFunction(int num)
                      {
                           return 1*num;
                      }
      
      	}
      INDICATOR2
      Code:
      public class OutsideIndicator : Indicator
      	{
      
              private InsideIndicator insInd;
              private int zzz;
      		protected override void OnStateChange()
      		{
      			if (State == State.SetDefaults)
      			{
      				def	                                                                = 1;
                                      zzz                                                                   = 0;
      				BarsRequiredToPlot					= 1;
      				AddPlot(Brushes.Blue, "TheTlop");		
      			}
      			else if (State == State.Configure)
      			{
      			} 
                              esle if (State == State.DataLoaded)
                              {
                                   insInd = InsideIndicator(def);
                               }
      		}
      
      		protected override void OnBarUpdate()
      		{
      			//Add your custom indicator logic here.
      			insInd.multiplyAbc = 3; //my question here, this is possible?
                             // zzz = insInd.myFunction(35);  // second question  - it's possible to use "InsideIndicator" functions in  other indicator?
                              Value[0] = insInd.ThePlot[0]; 
      		}
      
      		#region Properties
      		[Range(1, int.MaxValue)]
      		[NinjaScriptProperty]
      		[Display(Name="def", Order=1, GroupName="Parameters")]
      		public int def
      		{ get; set; }
      		#endregion
      
      	}
      How to programmatically change multiplyAbc in "InsideIndicator" and receive updated value to OutsideIndicator.
      It's possible to use "InsideIndicator" functions in other indicator?
      Last edited by nordseven; 10-24-2017, 03:15 PM.

      Comment


        #4
        Hello nordseven,

        It would be possible to set the value of a public variable from another indicator.

        I've provided a link to an example of how you could use an Addon to set the value of a bool in a strategy which would cause the strategy to return on each BarUpdate.



        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        2 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        40 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X