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 AaronKoRn, Yesterday, 09:49 PM
      1 response
      18 views
      0 likes
      Last Post Rikazkhan007  
      Started by ageeholdings, Today, 07:43 AM
      0 responses
      12 views
      0 likes
      Last Post ageeholdings  
      Started by pibrew, Today, 06:37 AM
      0 responses
      4 views
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      9 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Working...
      X