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

How to code a general method in your script

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

    How to code a general method in your script

    Hi Ninjas,

    The purpose of this thread is very simple and general. I'm trying to create a method to have within a certain Strategy script. My method could be something like this:

    #region Variables
    private int x = 1; // counter
    #endregion

    public bool core ( int x )
    {
    if (x==1)
    {
    if (Any comparison )
    {
    return true;
    }
    return false;
    }
    }

    Something is wrong cause any time I try to compile, it gives me an error message like:

    " Not every code path gives a value "

    - Could you tell what is my mistake ?
    - Where must I declare this method ? I couldn't find good enough info in help

    Thanks

    #2
    Hi Pstrusi,

    Thank you for your post.

    The error indicates that the method is not returning a value outside of any conditions otherwise the method would not return anything.

    I tested out on my end and changed the bracket after the return false; to above the line.

    Code:
    #region Variables
    private int x = 1; // counter
    #endregion
    
    public bool core ( int x )
    {
         if (x==1)
         {
             if (Any comparison )
             {
                  return true;
              }
         }
    return false;
    }
    After this change I compiled and no longer received the error.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thank u Cal, it works, then I'm getting into developing all methods

      Regards
      Last edited by pstrusi; 09-11-2013, 11:19 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mongo, Today, 11:05 AM
      4 responses
      14 views
      0 likes
      Last Post Mongo
      by Mongo
       
      Started by traderqz, Today, 12:06 AM
      7 responses
      13 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Skifree, Today, 03:41 AM
      5 responses
      13 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by traderqz, Yesterday, 09:06 AM
      5 responses
      34 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by guillembm, Today, 11:25 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X