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 specify an instrument name for custom indicator from a strategy

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

    How to specify an instrument name for custom indicator from a strategy

    Hi!
    I'm using multi-instrument strategy. I'm calling a custom made indicator MyIndicator() from the strategy, but i need to specify the instrument with will be use for the calculations. I tried to do it in the indicator with this code: (this.Instrument.MasterInstrument.Name = "TF 12-15"; ), but I'm sure this is not the right way to do that. May main instrument is (TF 12-15) and the second are ^ADV and ^DECL. When the BarsInProgress == 0 , I call MyIndicatorer(),and it gets the result for he TF 12-15, but when BarsInProgress > 0, i need to do call something like that: MyIndicator("TF 12-15") to force the indicator to make calculation for TF. My question is: is it possible to do that and how.
    Thank you.

    #2
    Hello,
    I would recommend to add the dataseries in Initialize and then call the caluclation of the indicator based of the Close values of the added datasers for the IDataSeries argument of the indicator.
    For example the SMA has the following overload SMA(IDataSeries input, int period)[int barsAgo]
    You could get the SMA to calculate off of the secondary data series by doing the following:
    Code:
    protected override void Initialize()
    {
        Add("TF 03-16" , PeriodType.Minute, 1, MarketDataType.Last);
    }
    protected override void OnBarUpdate()
    {
       SMA(Closes[1], 20)[0];			
    }
    For more information on using multiple time frames and instruments please see the following link: http://ninjatrader.com/support/helpG...nstruments.htm
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Thanks!
      I did not notice that my custom indicator has overload with first parameter IDataSeries Input. I just add the Input DataSeries as a first parameter of MyIndicator(Closes[0], .....), and it works great.
      Thank you for the help.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Davidtowleii, Today, 12:15 AM
      0 responses
      3 views
      0 likes
      Last Post Davidtowleii  
      Started by guillembm, Yesterday, 11:25 AM
      2 responses
      9 views
      0 likes
      Last Post guillembm  
      Started by junkone, 04-21-2024, 07:17 AM
      9 responses
      68 views
      0 likes
      Last Post jeronymite  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      4 responses
      20 views
      0 likes
      Last Post trilliantrader  
      Started by mgco4you, Yesterday, 09:46 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X