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

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

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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        12 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        7 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        6 views
        0 likes
        Last Post nandhumca  
        Started by The_Sec, Today, 03:37 PM
        0 responses
        3 views
        0 likes
        Last Post The_Sec
        by The_Sec
         
        Started by GwFutures1988, Today, 02:48 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X