Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add instrument to chart in STRATEGY Analyzer

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

    Add instrument to chart in STRATEGY Analyzer

    How can I add instrument to chart in Strategy Analyzer? So, if it's impossible via script. But other ways are impossible too: all keys are inactive.

    If it impossible, how can I compare major instrument with minor in script?

    There are 2 instruments in script. First - major instrument ES, second - MSFT. And there are some conditions, if something occurs with MSFT, do something with ES.

    So, how to add MSFT on the ES chart to new panel? I'd like to see is everything works fine.I need to see minor instrument too.

    #2
    Hello alexstox,

    Thank you for your post.

    There is no method to add an instrument from the code to the chart (whether in the Strategy Analyzer or Chart).

    I recommend reviewing the material at the following link on using multiple instrument and time frames: http://www.ninjatrader.com/support/h...nstruments.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Ok. I think you will give this opportunity in further NT version.

      If it will be usful to somebody except me, this is how I analyze strategy for own instrument/indicator, that could be import to NT:
      1. Import to NT (it is particular story)
      2. Create new chart with your instruments. Update it offline.
      3. Upadate instrument from NT supported by data providers (File-->Connect-->"your provider"). Accept all messages about "unknown instrument".
      4. File-->Disconnect-->"your connection"
      5. Right click on chart --> Data series [or just Ctrl+F] --> choose your instrument --> change "Days to load" --> this will update empty chart for your instrument.
      6. Tools-->Options-->Data-->uncheck Get data from server
      7. File-->Connect-->"your provider"
      8. Run your Strategy.
      9. After any change in your instrument and to update NT instruments you should do everything around.
      ====================================== Good luck! ====================
      Last edited by alexstox; 10-13-2013, 02:56 PM.

      Comment


        #4
        What if assign every bar close of some stock (MSFT for example) to indicator? In that way indicator will show the same as stock. Can I add MSFT to indicator script?

        Comment


          #5
          Add instrument to chart in STRATEGY Analyzer

          Nice information shared here. I am so glad while reading this thread because I am also searching for this thread. Thanks for posting.

          Comment


            #6
            Originally posted by alexstox View Post
            What if assign every bar close of some stock (MSFT for example) to indicator? In that way indicator will show the same as stock. Can I add MSFT to indicator script?
            Yes it is possible to call a multi series indicator from another script.

            In the suggested example this would be less efficient as you would be calling an indicator that then adds a secondary series to get its value, instead of just getting its value by adding it to the parent script.

            Let me know if I can further assist.
            LanceNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Lance View Post
              Yes it is possible to call a multi series indicator from another script.

              In the suggested example this would be less efficient as you would be calling an indicator that then adds a secondary series to get its value, instead of just getting its value by adding it to the parent script.

              Let me know if I can further assist.
              Oh! Lance! Please, read carefully The main subject was to add chart of stock (or other instrument) to strategy analyzer! As I understood my last proposition is ONLY available tool? Please give advice how to script this better in indicator?

              To add chart of stock or other instrument separately (on new panel). Because using multi instrument in script give opportunity to coding but not to see what is happening with both main and secondary instrument.
              Last edited by alexstox; 01-13-2014, 04:29 PM.

              Comment


                #8
                Hello alexstox,

                Thank you for your post.
                Originally posted by alexstox View Post
                What if assign every bar close of some stock (MSFT for example) to indicator? In that way indicator will show the same as stock. Can I add MSFT to indicator script?
                This would work if you plotted the MSFT. For the indicator that would plot these values you would add the MSFT to the script and then process the OnBarUpdate() method code only when BarsInProgress = 1.

                Comment


                  #9
                  In indicator script write something like this?
                  Code:
                  Initialize()
                  Add(MSFT, daily); 
                  ..............
                  OnBarUpdate()
                  MyMSFTindicator.Set(Closes[1][0])

                  Comment


                    #10
                    Hello alexstox,

                    That is correct.

                    Comment


                      #11
                      Originally posted by alexstox View Post
                      In indicator script write something like this?
                      Code:
                      Initialize()
                      Add(MSFT, daily); 
                      ..............
                      OnBarUpdate()
                      MyMSFTindicator.Set(Closes[1][0])
                      Well, how to set plot attributes to this adding? "Add(MSFT, daily);" is not recognized by indicator as "Value[]"? So, after "Add(MSFT, daily);" in Initialize() I should "Add(new Plot(Color.Gray, "MSFTdaily"));" Then it will be recognized as new Values[]?

                      Comment


                        #12
                        Hello alexstox,

                        Thank you for your response.

                        You would need to familiarize yourself with the methods used at the following link for using multiple instruments and/or time frames in your code: http://www.ninjatrader.com/support/h...nstruments.htm

                        Comment


                          #13
                          Originally posted by NinjaTrader_PatrickH View Post
                          Hello alexstox,

                          Thank you for your response.

                          You would need to familiarize yourself with the methods used at the following link for using multiple instruments and/or time frames in your code: http://www.ninjatrader.com/support/h...nstruments.htm
                          Thank you. But I've used these methods earlier in strategy script. I just can't understand how this can help me in my question?
                          I did as indicated in previous post and everything works fine
                          Code:
                          protected override void Initialize()
                          {
                          ...............
                          Add("MSFT", PeriodType.Day, 1);
                          Add(new Plot(Color.Orange, "MSFT"));
                          ..........................
                          protected override void OnBarUpdate()
                          {
                          ...........................
                          Values[7].Set(Closes[1][0]);

                          Comment


                            #14
                            Hlelo alexstox,

                            Thank you for your response.

                            Unfortunately, I do not know the complexity of the code or the number of plots. However, I would simply use Value.Set(Closes[1][0]);

                            Comment


                              #15
                              I'd like to have opportunity to enter any of stocks name.
                              I wrote this, but it doesn't work. Please help.
                              Code:
                              #region Variables
                              private string myStock1 = "MSFT";
                              private string myStock2 = "AAPL";
                              private string myStock3 = "NO";
                              #endregion
                              ......................
                              protected override void Initialize() 
                              {
                              BarsRequired = 1;
                              ......................
                              if(MyStock1!="NO") Add(MyStock1, PeriodType.Day, 1);
                              if(MyStock2!="NO") Add(MyStock2, PeriodType.Day, 1);
                              if(MyStock3!="NO") Add(MyStock3, PeriodType.Day, 1);
                              			
                              Add(new Plot(Color.Orange, "myStock1"));
                              Add(new Plot(Color.Yellow, "myStock2"));
                              Add(new Plot(Color.Brown, "myStock3"));
                              .............................................
                              }
                              protected override void OnBarUpdate()
                              {
                              if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
                              	return;
                              Values[0].Set(Closes[0][0]);
                              Values[1].Set(Closes[1][0]);
                              Values[2].Set(Closes[2][0]);
                              }
                              
                              #region Properties
                              [Description("myStock1")]
                              [GridCategory("Parameters")]
                              public int MyStock1
                                      {
                                          get { return myStock1; }
                                      }
                              		
                              [Description("myStock2")]
                              [GridCategory("Parameters")]
                              public int MyStock2
                                      {
                                          get { return myStock2; }
                                      }
                              		
                              [Description("myStock3")]
                              [GridCategory("Parameters")]
                              public int MyStock3
                                      {
                                          get { return myStock3; }
                                      }
                              		#endregion

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Segwin, 05-07-2018, 02:15 PM
                              14 responses
                              1,789 views
                              0 likes
                              Last Post aligator  
                              Started by Jimmyk, 01-26-2018, 05:19 AM
                              6 responses
                              837 views
                              0 likes
                              Last Post emuns
                              by emuns
                               
                              Started by jxs_xrj, 01-12-2020, 09:49 AM
                              6 responses
                              3,293 views
                              1 like
                              Last Post jgualdronc  
                              Started by Touch-Ups, Today, 10:36 AM
                              0 responses
                              13 views
                              0 likes
                              Last Post Touch-Ups  
                              Started by geddyisodin, 04-25-2024, 05:20 AM
                              11 responses
                              63 views
                              0 likes
                              Last Post halgo_boulder  
                              Working...
                              X