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

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.
    JimNinjaTrader Customer Service

    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.
      JimNinjaTrader Customer Service

      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.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by xiinteractive, 04-09-2024, 08:08 AM
          5 responses
          13 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by swestendorf, Today, 11:14 AM
          2 responses
          6 views
          0 likes
          Last Post NinjaTrader_Kimberly  
          Started by Mupulen, Today, 11:26 AM
          0 responses
          2 views
          0 likes
          Last Post Mupulen
          by Mupulen
           
          Started by Sparkyboy, Today, 10:57 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by TheMarlin801, 10-13-2020, 01:40 AM
          21 responses
          3,918 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Working...
          X