Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling strategy from indicator

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

    Calling strategy from indicator

    Hi all,

    I'd like to know if there is a chance to pass information from an indicator to a strategy.
    Let's say I've an indicator where an entry level is calculated or showed (e.g. a drawing horizontal line on the chart) and I want to translate this in an order (clicking a button or clicking the mouse) on a strategy that has been previously created to be called from the indicator itself.

    Is that possible?

    If yes could you please provide me an example?

    Thanks.

    #2
    MAX,

    Strategies can already use indicators. The only thing it sounds like you would need to change is to create a public dataseries in your indicator that the strategy can access, and assign the entry level calculation to this data series.

    Thankfully we have a handy reference sample to show you how to do that here : http://www.ninjatrader.com/support/f...ead.php?t=4991
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks.

      I know this.

      What I need is something like having an indicator where, for example, I draw a parallel line on the chart, corresponding to a particular price, and send an order (stop, limit, whatever), through a strategy.

      I cannot use directly a strategy because I cannot draw objects. Is something to use discretionary and not automated, but I need indicator to draw and strategy to send orders.

      The alternative could be to use ATM with an indicator, but I think this can't be done.

      Hope this clarifiy.

      Comment


        #4
        Originally posted by MAX View Post
        Hi all,

        I'd like to know if there is a chance to pass information from an indicator to a strategy.
        Let's say I've an indicator where an entry level is calculated or showed (e.g. a drawing horizontal line on the chart) and I want to translate this in an order (clicking a button or clicking the mouse) on a strategy that has been previously created to be called from the indicator itself.

        Is that possible?

        If yes could you please provide me an example?

        Thanks.
        In your Strategy put this code:

        public class TradeManagerGlobal {
        public static string command = "";
        }
        ...
        if ( TradeManagerGlobal.command.Contains("BuyLimit")) ) {
        ... Parse the string
        ... Execute commands
        TradeManagerGlobal.command=""; // Clear the command
        }

        In your Indicator put this code:

        TradeManagerGlobal.command = "BuyLimit 92.40 ";

        Comment


          #5
          Thanks monpere, I will look over your code.

          Comment


            #6
            Hi monpere,

            which code must be inserted when you write:

            ...Parse the string
            ... Execute commands

            ?

            Thanks.

            Comment


              #7
              Originally posted by MAX View Post
              Hi monpere,

              which code must be inserted when you write:

              ...Parse the string
              ... Execute commands

              ?

              Thanks.
              'Parse the string', would be your customized code to get the limit price of '92.40' into a variable 'entryPrice' for instance.

              'Execute commands' would be your entry order code like: EnterLongLimit (entryPrice);

              etc.

              Comment


                #8
                You mean you need to "unpack" the string from the command in order to get the entry price 92.40?

                Comment


                  #9
                  That was just an example, you can put anything you want in the string from the indicator side, and parse that data out from the strategy side. If you don't want to do string parsing, just change the structure to what you want, for example:

                  public class TradeManagerGlobal {
                  public static string orderCommand;
                  public static int quantity;
                  public static double limitPrice;
                  public static double stopPrice;
                  public static double trailPrice;
                  //...etc.
                  }

                  Comment


                    #10
                    Thanks.

                    So, in this last example you shouldn't use a string command in the indicator but, instead, split each information as variable and match those variables in the strategy?

                    Is that correct?

                    Comment


                      #11
                      Originally posted by MAX View Post
                      Thanks.

                      So, in this last example you shouldn't use a string command in the indicator but, instead, split each information as variable and match those variables in the strategy?

                      Is that correct?
                      That is correct.

                      Comment


                        #12
                        monpere, I put the code
                        Code:
                        if ( TradeManagerGlobal.command.Contains("BuyLimit")) ) {
                        ... Parse the string
                        ... Execute commands
                        TradeManagerGlobal.command=""; // Clear the command
                        }
                        in the strategy on the OnBarUpdate.

                        Order is submitted, but is cancelled as soon as the next bar comes out.

                        Am I missing something?

                        Thanks

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        558 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        324 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        545 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        547 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X