Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Called and calling indicator!

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

    Called and calling indicator!

    Hello, is there a way to find out if an indicator is “called/run” direct from the indicator-window-interface or if it is called from another indicator?

    I have a problem due to this. My indicator (the called one = A) only run one time for CurrentBar == 0 and no more, when called from another indicator (the calling one = B).

    My problem is that I do stuff in State.Transition assuming that Ind-A has run for all CurrentBars [0,lastindex]. When that is not the situation (only run one time for CurrentBar == 0), I will have problem in my State.Transition!

    Second question: What is the design-rule for an indicator to avoid this problem?

    Thank you/andbro

    Ind-A:

    else if (State == State.Transition)
    Print("At this point I have no idea whether the statement 'if (CurrentBar == 999)' has been excecuted or not");
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    items[0] = 1;

    if (CurrentBar == 999)
    Print("Call your wife at her birthday. VERY IMPORTANT");
    }

    Ind-B
    protected override void OnBarUpdate()
    {
    if (CurrentBar == 0)
    foo[0] = A().Items[0];
    }

    #2
    Hello AndBro,

    Thank you for writing in today.

    I have seen your inquiry and I will respond with with a complete answer of my findings.

    Thanks in advance for your patience.

    Comment


      #3
      Hello AndBro,

      There is no functionality that allows an indicator to know if it has been called from another NinjaScript or added from the indicators menu.

      It is possible to expose variables within your indicator so its code path can be modified externally from another indicator or strategy. Here is a link to a post outlining the process involved in revealing variables. There is a well commented sample script as well.



      I am unsure of what you want to execute in State.Transition. Since it is called once between historical and real time data, it will only return one bar from the indicator. Here is the section of the help guide that describes what each state is used for.



      Please let me know if I may be of further assistance.
      Last edited by NinjaTrader_Jim; 12-27-2016, 07:55 AM.

      Comment


        #4
        Hello Jim and thank you for your answer. After thinking of your answer and my experience, I come up with this conclusion:

        An indicator with an exposed variable must be designed (the indicator) so that the exposed variable will have a value for every possible value of CurrentBar, because the indicator might only be called only ONE time with a particular value of CurrentBar. Don’t assume the indicator will be called for every possible value of CurrentBar when called by another indicator. Correct or not correct?

        You asked me about State.Transition. Well, I use State.Transition as the point where CurrentBar has reached its end. I then do my drawings. I do not want to mess my indicator logic with drawing-instructions, so that is why I do that in State.Transition.
        Instead of doing “whatever” when CurrentBar == lastbar in OnBarUpdate(), I do that in State.Transition. Good or Bad?

        Comment


          #5
          Hello AndBro,

          An indicator with an exposed variable must be designed (the indicator) so that the exposed variable will have a value for every possible value of CurrentBar, because the indicator might only be called only ONE time with a particular value of CurrentBar. Don’t assume the indicator will be called for every possible value of CurrentBar when called by another indicator. Correct or not correct?
          Correct.

          Since State.Transition is described as called once as the object has finished processing historical data but before it starts to process realtime data, I would suggest implementing your code within OnBarUpdate() as you have outlined in your last post.

          If you have any other questions, please don't hesitate to ask.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          557 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