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 Brevo, Today, 01:45 AM
        0 responses
        3 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        239 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X