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 agclub, 04-21-2024, 08:57 PM
        4 responses
        18 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Irukandji, Today, 04:58 AM
        0 responses
        3 views
        0 likes
        Last Post Irukandji  
        Started by fitspressoburnfat, Today, 04:25 AM
        0 responses
        2 views
        0 likes
        Last Post fitspressoburnfat  
        Started by Skifree, Today, 03:41 AM
        1 response
        4 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by usazencort, Today, 01:16 AM
        0 responses
        4 views
        0 likes
        Last Post usazencort  
        Working...
        X