• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cant execute functions from "Custom Methods"

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

    Cant execute functions from "Custom Methods"

    I have created my small "addon" library file, MyMethod.cs.

    Code:
    namespace NinjaTrader.NinjaScript.AddOns
    {
    	public class MyMethods : NinjaTrader.NinjaScript.AddOnBase
    	{
    		
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description									= @"Enter the description for your new custom Add on here.";
    				Name										= "MyMethods";
    			}
    			else if (State == State.Configure)
    			{
    			}
    		}
    
    
    		
    		
    		public static void MyFunc_1(string url){
    
    			Print("a"); 
    		}
    .......
    ......
    UPDATE:
    when i call `Print` in that "MyMethods" class, i get error:

    "An object reference is required for the non-static field"
    Last edited by TazoTodua; 08-21-2017, 04:39 PM.

    #2
    Hello selnomeria,

    Your class is not a static class.

    Have you created a new instance of your class in your script?

    new MyMethods()
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Sorry, made a fault. I wanted to mean, that when i call "Print" from that MyMethods. class, then i get that error.

      How to call Print from there?

      Comment


        #4
        Hello selnomeria,

        To print from an addon use NinjaTrader.Code.Output.Process().

        For example:

        NinjaTrader.Code.Output.Process("My message", PrintTo.OutputTab1);
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          yes, and why there is no simpler (easy to remember way ( )
          ok, thanks!

          btw, is there somewhere documented NinjaTrader.Code.. ?

          Comment


            #6
            Hello selnomeria,

            Print is part of the NinjaScriptBase.

            Addons are not within this namespace framework.

            Below is a link to the help guide on Debugging where this is documented.
            http://ninjatrader.com/support/helpG...g_concepts.htm
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jrm999, Today, 07:44 PM
            0 responses
            2 views
            0 likes
            Last Post jrm999
            by jrm999
             
            Started by Iargo, Today, 05:53 PM
            0 responses
            3 views
            0 likes
            Last Post Iargo
            by Iargo
             
            Started by kadan, Today, 05:24 PM
            1 response
            5 views
            0 likes
            Last Post kadan
            by kadan
             
            Started by mntemel, Today, 04:17 PM
            0 responses
            8 views
            0 likes
            Last Post mntemel
            by mntemel
             
            Started by guigs88, Today, 02:57 PM
            2 responses
            4 views
            0 likes
            Last Post guigs88
            by guigs88
             
            Working...
            X