Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Executing a Ninjatrader 8 indicator via an Add-On

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

    Executing a Ninjatrader 8 indicator via an Add-On

    Hi! I've been searching high and low on how to do this, but to no avail. Is it possible to build an Add-On that can execute an indicator and return the values?

    For example, the code below (from your documentation) allows you to Request a Bars<T> for use. Is there a way to similarly remotely instantiate an indicator?

    For example, can you request Bars (like below), Request and initialize an indicator, pass in a BarsArray and input params like you would from a strategy? I know there is an easy answer, I just can't find it. I'm going to read the help documentation again, but if you could point me in the right direction, I can figure it out from there.

    When you commented : // Do something with the returned bars here. can you pass them along to an indicator for execution? (I'm repeating myself, sorry, you get what I'm asking)

    // Request the bars
    barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
    {
    if (errorCode != ErrorCode.NoError)
    {
    // Handle any errors in requesting bars here
    NinjaTrader.Code.Output.Process(string.Format("Err or on requesting bars: {0}, {1}",
    errorCode, errorMessage), PrintTo.OutputTab1);
    return;
    }

    // Do something with the returned bars here.
    for (int i = 0; i < bars.Bars.Count; i++)
    {
    // Output the bars
    NinjaTrader.Code.Output.Process(string.Format("Tim e: {1} Open: {2} High: {3} Low: {4} Close: {5} Volume: {6}",
    bars.Bars.GetTime(i),
    bars.Bars.GetOpen(i),
    bars.Bars.GetHigh(i),
    bars.Bars.GetLow(i),
    bars.Bars.GetClose(i),
    bars.Bars.GetVolume(i)), PrintTo.OutputTab1);
    }
    }));



    Thank you much for any assistance!

    - Mike

    #2
    Hello,

    Thank you for the question.

    This is a topic that has come up before but currently there is no documented or supported methods to call a indicator from an Addon specifically. The addon base would only have Type access to the indicators so you would not have the same access as a Strategy or Indicator where you can call the indicator by name or SMA() by its wrapper code.

    This is a topic being reviewed by development but currently there are no specific ways to address this.
    On thought as a work around for simple indicators, in theory move the indicators code into the addon its self, and then execute the local code in OnBarUpdate to calculate values. You would need to account for historical and realtime data in the calculation so I am unsure of any problems you may run into going that route.

    I have added a vote to this item for further review.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks!

      Thanks Jesse for the information.

      I kinda assumed i may have to be a little creative. Type reference may be enough I think.. I.E - Get the indicators full string, parse the parameters, create a reference to Type GetType "NinjaTrader.Indicator.Indicator" (in NT7 that was the correct string for GetType indicator) create a MethodInfo object of the referenced TypeVar.GetMethod and cast that MethodInfoVar.Invoke(methodparamaters) to an Indicator var to run in the Add-On without calling it by name. I use a similar hack in NT7 (that I found someone else was using in an free indicator - no such thing as an original idea) to create different TimeFrame/BarType indicators within an Indy or Strat without having to Add() it and use BarsInProgress to reference it - and Invoked indy's output is exactly the same if you were to program it properly. But I was running that code in a class extended by Indicator or Strategy. Could do a partial.

      Not sure if it would work in an Add-On due to method protection levels. But could always reflect the internals. hmmmm Ya got me thinking it's quite possible.

      But without having to hack it, I'm surprised that an Add-On, which is inherently supposed to be the gateway in (i think), does not allow direct reference to, what I feel are the main objects of the system, Strategies and Indicators (I'm simplifying it, yes, but they are used often. That would open up a whole new world of what could be built into the platform.

      Don't know enough about NT8's internals to know if that would still work. But I'm getting a good handle on it all. The openness of the platform is brilliant, except for this specific issue. But good job on NT8 btw - y'all nailed it. I'll give it a go and keep you posted.

      Cheers,

      mike

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Kaledus, Today, 01:29 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by frankthearm, Yesterday, 09:08 AM
      13 responses
      45 views
      0 likes
      Last Post frankthearm  
      Started by PaulMohn, Today, 12:36 PM
      2 responses
      16 views
      0 likes
      Last Post PaulMohn  
      Started by Conceptzx, 10-11-2022, 06:38 AM
      2 responses
      55 views
      0 likes
      Last Post PhillT
      by PhillT
       
      Started by yertle, Yesterday, 08:38 AM
      8 responses
      37 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Working...
      X