Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Call a Strategy

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

    Call a Strategy

    Hello all,
    Is it possible to call a custom ninjascript strategy from within a custom indicator?

    i.e. The indicator detects a specific event and within the indicator code we check to see if this is true, if so, we want to run our strategy which we use to enter the market and put our stop loss, etc.

    #2
    Hello, thanks for your post.

    There is no support for an indicator to call a strategy, you can instantiate indicators within your strategies to use their data while the strategy is running. You can add multiple data series to your script with AddDataSeries() and calculate indicator data for more than just the primary series as well, e.g.

    State.DataLoaded:
    mySMA = SMA(BarsArray[1], 14); //14 period sma set up on the secondary series.

    If you want to submit orders through an indicator, you can also add an Addon style Account object to your indicators and submit orders using the Submit() method. See here for an example of setting that up:

    https://ninjatrader.com/support/help...ount_class.htm

    Please let me know if I can assist any further.

    Comment


      #3
      Chris,
      I'd like to make sure I understand your response. You are saying I can do the opposite; run my strategy which can call my indicator. Since the indicator was called within my strategy it will have all the data available to the indicator?

      Comment


        #4
        Hello, thanks for the follow up.

        Yes, we support indicators being called from strategies. The indicator must expose a public series or a Plot to be available to access from the strategy. For an example of this see the MACD indicator and its public Plot series e.g.

        Code:
        [Browsable(false)]
        [XmlIgnore]
        public Series<double> Avg
        {
            get { return Values[1]; }
        }
        
        [Browsable(false)]
        [XmlIgnore]
        public Series<double> Default
        {
            get { return Values[0]; } 
        }
        
        //and so on
        We also have an example here for study:
        https://ninjatrader.com/support/help...alues_that.htm

        Please let me know if I can assist any further.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        83 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        45 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        65 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        68 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        57 views
        0 likes
        Last Post CarlTrading  
        Working...
        X