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

Using Initialize Function Manually

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

    Using Initialize Function Manually

    Hello Support,

    I am developing a solution as an indicator, that requires me to take several inputs from the user from another application. Now, one of those inputs is the instruments that the indicator needs.

    Now, as you know that we can only add instruments to an indicator (or a strategy for that matter) only in the Initialize method. So, i need to be able to get the inputs from the user (which i have all figured out) and then initialize the indicator using those inputs and adding the required instruments.

    Now, i have been trying out different solutions, one that seems plausible is that i explicitly call the Initialize method once the user is done with entering the inputs. So there would be something like this in my OnBarUpdate method:

    Code:
    protected override void OnBarUpdate()
            {
    			if(DataReceived)
    			{
    				//Set a data structure to hold the input data
    				Initialize();
    			}
            }
    This works as per the initial tests i have done. What i need to confirm from you guys (the NT developer team in specific) is whether this would cause any specific problems? If so then what should i expect?

    I would very much appreciate a quick response on this. Hoping to hear from you soon.

    Thanks
    Umer

    #2
    Update:

    I just tried a very simple test, and it turns out that i can not call the Add method, from inside the call hierarchy of the OnBarMethod.

    Now, my question would be whether there is a way to do what i want to achieve? Any suggestions from you guys?

    Comment


      #3
      Hello Umer,

      Thank you for your post.

      If you are using Add() methods in the Initialize, then when you have OnBarUpdate called you can run into errors saying that you can only call Add() in the initialize. This would be expected and would 'break' your code.

      If you are wanting to add these data series in a 'later' time then you would want to take a look at the Pivots indicator as a good starting point.

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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      18 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Working...
      X