Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use indicator in Strategy

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

    How to use indicator in Strategy

    Hello,

    I have downloaded a indicator code from this forum and i want to develop similar kind of indicator.

    This indicator are using several parameters like Primary Instrument, Secondary instrument, same type of subscription and some other configurable parameters. It overrides base indicator method like OnInitialize(), OnStartup and OnBarUpdate. And given every section, it uses these passing parameters and do some verficatons.

    My problem is that how do i use this indicator in my strategy. I am attaching the indicator zip file. Please check and send simple strategy logic in each section. (OnInitialize, OnBarUpdate, etc)

    Thank you.

    Regards,
    Ziaul
    Attached Files

    #2
    Hi Ziaul,

    Thank you for posting

    I would recommend that you create an indicator that you would use to calculate your own spread. You would also need to understand how the indicator is going to plot on the chart and what kind of results it would generate so you can accurately more gauge your strategy.

    However, we do a couple of other spread type indicators available from the forum as well.
    http://www.ninjatrader.com/support/forum/local_links.php?action=ratelink&linkid=367&catid=4 &lpage=9

    http://www.ninjatrader.com/support/f...atid=4&lpage=9

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much. I am already aware with this given link.

      My problem is how to use this indicator in my strategy? I need sample strategy code.

      Comment


        #4
        Ziaul,

        Unfortunately, I do not have any sample code for the Spread indicator in a Strategy.
        However, I will keep this thread open for any of our other users who may have some experience in this matter.

        Additionally, take a look at our reference samples and NinjaScript file sharing on our forum.
        http://www.ninjatrader.com/support/forum/

        Let me know if I can help with anything else.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          It doesn't much surprise me that I found this thread given I and I am sure many others have this same requirement - primariliy the requirement to trade multiple instruments on a spread basis.

          My original reason today for my search was that I was going to ask if there was any way to save an Indicator as a Strategy and then make minor modification required to trade. The reason for the question is that most of us have indicators for this, but where we're having issues are with the actual automated trading side of things.

          I suspect the answer is "no", three is no way to save and Indicator as a Strategy.

          Here's a suggestion that will not only have universal support for a great many NinjaTrader users, but even more so should have been incorporated into NinjaTrader quite a number of years ago...which is... how about we get going on a spread trader built into the platform!

          Great product, but what a city-sized hole you have here. This should be standard equipment by now.

          Comment


            #6
            Currently this is not available however I have forwarded this to our development team as a suggestion on how we can improve the NinjaTrader platform. Once this suggestion has been input into our tracking system I will forward you the assigned ID number for tracking.
            Christopher J.NinjaTrader Customer Service

            Comment


              #7
              copy and paste into strategy?


              The best thing to do is create the indicator in the strategy by calling the constructor.



              Originally posted by Steve R View Post
              It doesn't much surprise me that I found this thread given I and I am sure many others have this same requirement - primariliy the requirement to trade multiple instruments on a spread basis.

              My original reason today for my search was that I was going to ask if there was any way to save an Indicator as a Strategy and then make minor modification required to trade. The reason for the question is that most of us have indicators for this, but where we're having issues are with the actual automated trading side of things.

              I suspect the answer is "no", three is no way to save and Indicator as a Strategy.

              Here's a suggestion that will not only have universal support for a great many NinjaTrader users, but even more so should have been incorporated into NinjaTrader quite a number of years ago...which is... how about we get going on a spread trader built into the platform!

              Great product, but what a city-sized hole you have here. This should be standard equipment by now.

              Comment


                #8
                Originally posted by sledge View Post
                copy and paste into strategy?
                Now you're talking, but I fear a copy-paste is not feasible as there'd likely be something I would fudge up or miss.

                I'm assuming if it were easily doable an NT rep would have suggested it? I say this only because it was the first thing that came to my mind too.



                The best thing to do is create the indicator in the strategy by calling the constructor.
                Now that my friend, I know nothing about. More on that might get me over the hump.

                Comment


                  #9
                  Originally posted by Steve R View Post
                  Now you're talking, but I fear a copy-paste is not feasible as there'd likely be something I would fudge up or miss.

                  I'm assuming if it were easily doable an NT rep would have suggested it? I say this only because it was the first thing that came to my mind too.





                  Now that my friend, I know nothing about. More on that might get me over the hump.
                  In my indicator, I've made all my variables that I want to use public.

                  So in your strategy:

                  variables section

                  private Indicator1 ind1;


                  Strategy's OnStartUp()

                  ind1 = Indicator1(BarsArray[0], Color.Orange, parameter3, parameter4, etc );


                  Strategy's OnBarUpdate()

                  if ( ind1.variable1 > 33 )
                  {
                  Print ( "Hi ind1.var = " + ind1.variable1 );
                  }

                  Comment


                    #10
                    Originally posted by sledge View Post
                    In my indicator, I've made all my variables that I want to use public.

                    So in your strategy:

                    variables section

                    private Indicator1 ind1;


                    Strategy's OnStartUp()

                    ind1 = Indicator1(BarsArray[0], Color.Orange, parameter3, parameter4, etc );


                    Strategy's OnBarUpdate()

                    if ( ind1.variable1 > 33 )
                    {
                    Print ( "Hi ind1.var = " + ind1.variable1 );
                    }
                    thanks man, that almost looks do-able for me. So my variables are private in the indicator so I would go ahead and set them to public, correct?

                    Here's a question that comes up right away. I need to set several variables up in the indicator. How do I get access to those variables to set them before the strategy runs?

                    Comment


                      #11
                      SteveR,

                      You can create user defined inputs that will allow you to adjust those variable before starting the strategy.

                      Below is a link from support forum on how to accomplish this.
                      http://www.ninjatrader.com/support/f...ead.php?t=3420
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Cal View Post
                        SteveR,

                        You can create user defined inputs that will allow you to adjust those variable before starting the strategy.

                        Below is a link from support forum on how to accomplish this.
                        http://www.ninjatrader.com/support/f...ead.php?t=3420
                        I have user defined variables already in the indicator. If I call the indicator from the strategy, how does it get the user input? Does it 'bring into' the Strategy, the Indicator, and before running will allow me to input my indicator variables as if I was running the Indicator directly?

                        Comment


                          #13
                          SteveR,

                          Your strategy will not pull that user define input in your strategy. However, when you call that indicator in your strategy you have to set up the parameters you want that indicator to work off of. It is here that you can setup your user defined inputs and use the strategy to determine how you want the indicator to calculate.
                          Cal H.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Cal View Post
                            SteveR,

                            ...It is here that you can setup your user defined inputs and use the strategy to determine how you want the indicator to calculate.
                            Where? Where is 'here'?

                            I figured the question was simple. "Where"?

                            Let's get an example going on because I am still not seeing the answer I'm looking for.

                            1 - I've got an indicator already.
                            2 - I have 3 user input variables for the indicator. 2 floats and an int. I can't hard-code them because they're vastly different depending on time-frame and security.

                            3 - When I "Call" the indicator in my Strategy, at what point will the strategy (or indicator) be asking me for those numbers so the Indicator and thusly Strategy will work?

                            I realize that once the Strategy has the indicator's values etc how it'll work, but I am unclear as to how the indicator will be obtaining from me, the values I want to use for the Indicator and thusly the strategy.

                            _____

                            Part # 2:

                            Sledge used this code:

                            Strategy's OnStartUp()

                            ind1 = Indicator1(BarsArray[0], Color.Orange, parameter3, parameter4, etc );
                            From here that looks to me like I use the Strategy to ask for the variables IT has set up, and then IT sends the variables (parameters) TO the indicator to use..

                            I have no idea if that's how it works.....but if it does, then the next questions would be, in which order is my Indicator getting those parameters and for which if its variables.

                            Again this whole "Part 2" may be moot because it's not how it works at all?, but I figured this wasn't already confusing enough for such a simple question, that I'd just go ahead and add to the pile :-)

                            Comment


                              #15
                              OK I just spent the last hour fooling around with a blank Strategy, calling my Indicator. I figured it would be the only way to see what was really going on.

                              I see it does work like I thought from my last "Part #2 : Sledge Code" idea.

                              So I made variables in the Strategy that match the input I needed for the Indicator.

                              From there I called the indicator using the strategy's variables as inputs (I found once I started typing that a "message box" came up and showed the input order that the Indicator would be looking at for its variables).

                              From there I ran some simple if statements etc and pulled out variables (public) FROM the indicator into the Strategy that I could use as I wished, so I can indeed also see all the variables from both the strategy and the Indicator. IE I can access everything I need to from within the Strategy.

                              Holy what a mouthful!

                              Anyway, so one final question..

                              I'm going to use this particular NT Strategy to call ATM Strategies because in this case it's an easier manage..so the question is......if I set the NT Strategy to make only say 3 trades in one direction, will it abide by that or will anything else ever over-run that parameter? I don't want to wake up being 35 trades in one direction....

                              Can I assume that after the NT strategy does its "buy" thing, the ATM Strategy will take over for stops, trails, profits etc??

                              I can see that light at the end of the tunnel. It still sounds like a train :-)

                              Admittedly the ATM Strategies are even newer to me than last week's calling the indicator from within a strategy - which again BTW, thank Sledge, if you're reading. This has been a very nice addition - or at least will be moving forward.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              574 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X