Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The indicator can not be attached to the graph.

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

    The indicator can not be attached to the graph.

    Hello!

    After compilation, I am not receiving any error message. I have tried to have the behaviour on the output window, and I have printed something such as 2*3, and the correct result is appearing on the output window.

    When I am attaching the indicator on the graph, I have the mention ....
    Calculating...
    and the indicator never appears on the graph and also the metion calculating does not disappear.

    I am suspecting the loop
    HTML Code:
    while (count < 4)
    , but I am not sure and also, I do not know what I could replace it with.

    I have the following code:
    HTML Code:
    private Series<double>[] mySeries;
    .
    .
    .
    HTML Code:
    else if (State == State.DataLoaded)
    {
      mySeries = new Series<double>[50];
      for (int aa = 0; aa < mySeries.Length; aa++)
      {
        mySeries[aa] = new Series<double>(this, MaximumBarsLookBack.Infinite);
      }
    }
    HTML Code:
    protected override void OnBarUpdate()
    {
      if(CurrentBar < 500)
          return;
    
        for (int ii = mySeries.Length-10; ii > 0 ; ii--)
        {
          while (count < 4)
          {
            for (int k = 0; k < 75; k++)
            {
              if (mySeries[count][k] > 0.0)
              {
    //           myLogic here
              }
            }
            count++;
          }    
    
        }​
    }
    I would appreciare if someone could point out where the problem is located.

    Best regards,​

    #2
    Hello Stanfillirenfro,

    Thank you for your post.

    It is likely that your OnBarUpdate() logic, such as the while loop you mentioned, is causing the script to be stuck calculating. Loops are a general C# concept and are not NinjaScript-specific, so we do not offer support with looping logic in general. You can research these topics via external resources if you need help with the looping parts of your code. We have a very basic guide on looping with some examples here:


    If a loop gets stuck, this could cause a thread to become locked and then your indicator will show that it is calculating indefinitely. You may need to consider breaking the loop at some point to prevent this from happening. You could add additional prints throughout your script to help with the debugging process and to determine which part of your logic is getting stuck. The following post is a general overview of using prints to debug your scripts:


    If you have more specific questions about how to achieve something in your indicator's logic, please provide a description of your end goal and what you are hoping to achieve, as this is not clear based on the snippet you provided. That way, based on what you are looking to do, we could provide any helpful NinjaScript resources to help point you in the right direction.

    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

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