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

Calling another indicator in its entirety

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

    Calling another indicator in its entirety

    I have two indicators, Indicator A and Indicator B.
    From 8:30am to noon I would want Indicator A to execute and from noon on, I would want Indicator B to execute.

    Is it possible to call for the entire indicator or only the variables of the indicator can be called? If affirmative, what would be the syntax for calling the entire indicator, because I am getting a compile error "No overload for method "Testing" takes "0" argument"

    Thanks in advance

    #2
    2Look4me, generally this should be possible as you can retrieve any exposed values such as plots from a called study as well. You would just need to pass in the parameters when calling it as seen in the Intellisense signature of the method overload.

    i.e.

    YourIndicator(ParameterA, ParameterB, ....).SomePlotValue[0]
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Is the following possible:

      YourIndicator(if before noon) {Indicator A}
      else if (after noon) {Indiator B}

      But instead of calling in some plot values or variables from Indicator A and Indicator B, I would like to execute Indicator A and indicator B in its entirety?

      Comment


        #4
        Originally posted by 2Look4me View Post
        Is the following possible:

        YourIndicator(if before noon) {Indicator A}
        else if (after noon) {Indiator B}

        But instead of calling in some plot values or variables from Indicator A and Indicator B, I would like to execute Indicator A and indicator B in its entirety?
        You cannot execute an object. You query it for values of its public properties or execute/call/run its public methods.

        Comment


          #5
          Hello 2Look4me,

          Thank you for your response.

          Please take a look at examples of indicator methods at the following link: http://www.ninjatrader.com/support/h...indicators.htm

          For an example of calling an indicator in a strategy please go to Tools > Edit NinjaScript > Strategy > SampleMaCrossOver.

          Comment


            #6
            Thanks for the suggestions. On the other hand instead of calling another indicator ,
            Can a bool variable be declared inside an "if" statement? i.e.

            if (ToTime(Time[0] >= 83000 && ToTime(Time[0] < 120000 ) {
            bool Long = A>B && C>D
            bool Short = E<F && G<H }

            else if (ToTime(Time[0] >= 120000 && ToTime(Time[0] < 150000 ) {
            bool Long = A>B && E>F
            bool Short = C<D && G<H }

            if (Long) { do calculations}
            else if (Short) {do calculations}

            Is there a good way to accomplish the above without repeating the calculations too many times if the "bool variable" changes with time?

            Comment


              #7
              Originally posted by 2Look4me View Post
              Thanks for the suggestions. On the other hand instead of calling another indicator ,
              Can a bool variable be declared inside an "if" statement? i.e.

              if (ToTime(Time[0] >= 83000 && ToTime(Time[0] < 120000 ) {
              bool Long = A>B && C>D
              bool Short = E<F && G<H }

              else if (ToTime(Time[0] >= 120000 && ToTime(Time[0] < 150000 ) {
              bool Long = A>B && E>F
              bool Short = C<D && G<H }

              if (Long) { do calculations}
              else if (Short) {do calculations}

              Is there a good way to accomplish the above without repeating the calculations too many times if the "bool variable" changes with time?
              If you write it that way, you will have a scope issue. Instead, declare your bools as class variables, and then set/unset them as necessary.

              Comment


                #8
                Hello 2Look4me,

                Thank you for your response.

                As koganam stated, set these bools first in the Variables region of the code:
                Code:
                        #region Variables
                        private bool Long = false;
                        private bool Short = false;
                        #endregion

                Comment


                  #9
                  Thanks again. That helps resolve the scope issues that koganam was referring to.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by GussJ, 03-04-2020, 03:11 PM
                  16 responses
                  3,279 views
                  0 likes
                  Last Post Leafcutter  
                  Started by WHICKED, Today, 12:45 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post WHICKED
                  by WHICKED
                   
                  Started by Tim-c, Today, 02:10 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by Taddypole, Today, 02:47 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post Taddypole  
                  Started by chbruno, 04-24-2024, 04:10 PM
                  4 responses
                  51 views
                  0 likes
                  Last Post chbruno
                  by chbruno
                   
                  Working...
                  X