Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add instrument to chart in STRATEGY Analyzer

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

    #76
    So, what should I do now?!

    Let me explain carefully what I have in strategy.
    1) For example, I trade EURUSD - master instrument
    2) MyIndex(MyIndex1) is an indicator that can show me chart of instrument MyIndex1="MSFT" in Strategy Analyzer in addition to master instrument chart.
    3) Data history for EURUSD begins from 1990 year
    4) Data history for MSFT begins from 1994 year
    4) If I set 1994-2014 in Strategy Analyzer - everything is OK!!!
    5) BUT when I set 1990-2014 - this error occurs.

    That's why I concluded this error because of lack of data in the 1990-1993 years. And that's why I ask how to define "nothing" or "no data".

    So, what should I do?

    Comment


      #77
      Understood thanks for summarizing that, here is what you need.

      You need the equivalent of this for multi time frame: http://www.ninjatrader.com/support/f...ead.php?t=3170

      Which is explained here in some more detail in section: Using Bars Objects as Input to Indicator Methods




      // Checks to ensure all Bars objects contain enough bars before beginning
      if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
      return;


      Basically this check you need for each multi time frame object so the script does not try to run on a series which does not have enough data.

      Comment


        #78
        I already have these in my strategy and indicator script. Didn't help. How can I send you a message?

        Comment


          #79
          k yea will need to take a look then as there must be something minor missing then.

          Send me an email with ATTN: Brett in the subject and include the script to support at ninjatrader dot com .

          Comment


            #80
            k yea will need to take a look then as there must be something minor missing then.

            Send me an email with ATTN: Brett in the subject and include the script to support at ninjatrader dot com .

            Comment


              #81
              So, my strategy:
              1) For example, I trade EURUSD - master instrument
              2) MyIndex(MyIndex1) is an indicator that can show me chart of instrument MyIndex1="MSFT" in Strategy Analyzer in addition to master instrument chart.
              3) Data history for EURUSD begins from 1990 year
              4) Data history for MSFT begins from 1994 year
              4) If I set 1990-2014 in Strategy Analyzer - there is one thing: strategy trades even befor first value of MyIndex(MyIndex1).
              As for master instrument I usually use
              if (CurrentBars[0] <= 100) return;
              So, what should I use for indicator MyIndex(MyIndex1) to set strategy to trade only after first indicator value appeared.

              Comment


                #82
                To specifically address your question put the following code near the CurrentBar return check at the top of the file.



                if (!MyIndex(MyIndex1).ContainsValue(0)) return;

                Comment


                  #83
                  Originally posted by NinjaTrader_Brett View Post
                  To specifically address your question put the following code near the CurrentBar return check at the top of the file.



                  if (!MyIndex(MyIndex1).ContainsValue(0)) return;
                  Only with this it works
                  if (!MyIndex(MyIndex1).Value.ContainsValue(0)) return;

                  Comment


                    #84
                    Great,

                    Yea I'm not sure how your indicator is structured so I offered pseudo code but yea you needed to set what plot specifically you wanted to check against.

                    Comment


                      #85
                      Indicator data type as OHLC

                      Hello. So, I learned to add instrument as indicator to Analyzer chart. BUT it's adding as Line data type chart. How to add it as OHLC type? Can Indicator represent instrument as OHLC?

                      Now I have that code in indicator:

                      Add("MSFT", PeriodType.Day, 1);
                      Add(new Plot(Color.Orange, "MSFT"));


                      P.S. If I add MSFT to strategy, is it added as OHLC or only closes?
                      Last edited by alexstox; 03-23-2014, 08:25 AM.

                      Comment


                        #86
                        Hello alexstox,

                        A Plot can only have one value so it would not be able to contain the OHLC values in one plot but you may have four different plots so that one plot can have the Open value, another plot can have the High value and so on to be able to get what you are looking for.

                        protected override void Initialize()
                        {
                        Add(new Plot(Color.Gray, PlotStyle.Line, "OpenValue"));
                        Add(new Plot(Color.Gray, PlotStyle.Line, "HighValue"));
                        Add(new Plot(Color.Gray, PlotStyle.Line, "LowValue"));
                        Add(new Plot(Color.Gray, PlotStyle.Line, "CloseValue"));
                        }
                        JCNinjaTrader Customer Service

                        Comment


                          #87
                          What should I do in this case: I added MSFT to strategy. I need to check ATR indicator on MSFT, but not only on Close data but on OHLC of MSFT. But how can I add OHLC to ATR?

                          Comment


                            #88
                            Hello alexstox,

                            You may use the same method as the "Using Bars Objects as Input to Indicator Methods" in Brett's respond in Post #77.

                            So if "MSFT" is the only bars object that you added in your Strategy you may call "ATR(BarsArray[1], atrPeriod)[0]"

                            This way you are passing the "ATR" the DataSeries object of the "MSFT" price which has the Open, High, Low and Close values.
                            JCNinjaTrader Customer Service

                            Comment


                              #89
                              Dear JC, does this work similar for indicator script? If look at my example, when I add stock to indicator to represent it in Strategy Analyzer chart

                              protected override void Initialize()
                              {
                              ................
                              Add("MSFT", PeriodType.Day, 1);
                              ................
                              Add(new Plot(Color.Orange, "MSFT"));
                              ................
                              }

                              protected override void OnBarUpdate()
                              {
                              ................
                              Values[0].Set(Closes[1][0]);
                              ................
                              }


                              So, Closes[1][0] mean that I add only Closes of MSFT, is it? Can I add BarsArray[1] in indicator?

                              Comment


                                #90
                                Hello alexstox,

                                Plots will not work the same inside of a Strategy so you would not be able to use inside of a Strategy.

                                Yes, that is correct Closes[1][0] would be the Close value for the "MSTF" instrument in this example.

                                The easiest way to get the Close value on your chart for the "MSTF" is to draw a line using a drawing object inside of your strategy.
                                JCNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by ghoul, Today, 06:02 PM
                                3 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                3 responses
                                44 views
                                0 likes
                                Last Post jeronymite  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                7 responses
                                20 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                10 responses
                                180 views
                                0 likes
                                Last Post jeronymite  
                                Started by DanielSanMartin, Yesterday, 02:37 PM
                                2 responses
                                13 views
                                0 likes
                                Last Post DanielSanMartin  
                                Working...
                                X