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 llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X