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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        44 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        58 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        35 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        95 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        59 views
        0 likes
        Last Post PaulMohn  
        Working...
        X