Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

unhandled exception error while indicator works.

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

    unhandled exception error while indicator works.

    Hi,

    I'm getting an "unhandled exception " error when I instantiate a reference to another custom indicator, even though the code performs as expected and I have error trapping around the problem line (which doesn't catch anything).

    Here's the relevant code:

    Code:
    private NinjaTrader.NinjaScript.Indicators.VWAPS.VWAPDaily  vwap;
    
    ....
    
    else if (State == State.DataLoaded)
    {
    try{		
    vwap = VWAPDaily(1,1.5,2,50,50,1,false,false,false,false,false,false,true);
    }catch (Exception ex) {Print (ex.ToString());}				
    }
    Any suggestions would be much appreicated.

    #2
    Hello palinuro,

    Thank you for the post.

    Currently, nothing is sticking out for me as to why you would get the error, I did want to check have you tried removing the try/catch and see what the error produced is?

    If not, could you do this and provide the error message you get? The try/catch is not always the best solution but the error in the log tab or output window should be more helpful.

    If this is causing a crash or something else to occur where you cannot see an error and that was the reason for the try/catch, could you instead provide an export of the indicator being used for me to review?

    I look forward to being of further assistance.

    Comment


      #3
      Jesse,

      Thanks for the response, that helped me look for the problem in the VWAP indicator, and I realized it's because it puts a button on the toolbar:

      Code:
      			else if (State == State.Historical)
      			{
      				if(!IsToolBarButtonAdded) AddToolBarButton();
      			}
      Is there a way to prevent that code from running if it is referenced in another indicator?

      Comment


        #4
        Hello

        Thank you for the reply.

        In this case one of the objects being used is likely null, without seeing the code in the AddToolBarButton() method I could only guess that it may be the ChartControl. Could you try the following modification to see if this resolves the error? If not, please post just the AddToolBarButton(); method and we could look at what may be happening.

        Code:
        else if (State == State.Historical)
        {
        	if(!IsToolBarButtonAdded[B] && ChartControl != null[/B]) AddToolBarButton();
        }
        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        48 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        36 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        95 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        59 views
        0 likes
        Last Post PaulMohn  
        Working...
        X