Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add instrument to chart in STRATEGY Analyzer

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

    #91
    So, my strategy:
    1) For example, I trade EURUSD - master instrument
    2) MyIndex("MSFT") is an indicator that can show me chart of instrument "MSFT" in Strategy Analyzer in addition to master instrument chart.
    3) UPDW(MyIndex("MSFT")) is an indicator that uses MyIndex("MSFT") and plot additional line on MyIndex("MSFT") chart.
    3) Data history for EURUSD begins from 1990 year
    4) Data history for MSFT begins from 2000 year
    4) If I set 1990-2014 in Strategy Analyzer - there is one thing: UPDW(MyIndex("MSFT")) plots line even before first value of MyIndex("MSFT") and automatically uses master instrument data (EURUSD).
    I need UPDW(MyIndex("MSFT")) should use only MyIndex("MSFT") data and shouldn't plot line before first data of MyIndex("MSFT") and don't use EURUSD data.
    As for master instrument I usually use
    if (CurrentBars[0] <= 100) return;
    So, what should I use in indicator UPDW(MyIndex("MSFT")) to plot line only after first indicator MyIndex("MSFT") value appeared.
    Click image for larger version

Name:	UpDwInd.PNG
Views:	1
Size:	94.8 KB
ID:	870147
    Last edited by alexstox; 04-04-2014, 01:12 AM.

    Comment


      #92
      Hello alexstox,

      I would suggest using a CurrentBars for each Series like it was discussed previous on this thread to ensure that your Strategy and/or Indicator are not being processed when you do not want them to.

      // Checks to ensure all Bars objects contain enough bars before beginning
      if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= 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.
      JCNinjaTrader Customer Service

      Comment


        #93
        How to write correct expression in indicator script
        if(Inputs[0].ContainsValue(0)) return;

        How to write you email?

        Comment


          #94
          Hello alexstox,

          ContainsValue() method is going to be mainly used for Indicators to ensure they have valid plots.

          See Brett's post on #82
          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;
          To send me an email you may send it to support [at] ninjatrader [dot] com with ATTN: JC in the subject.
          JCNinjaTrader Customer Service

          Comment


            #95
            It used for indicators in strategy script?

            Comment


              #96
              Hello alexstox,

              Yes, it can be used for Indicator inside of another Indicator or Strategy.
              JCNinjaTrader Customer Service

              Comment


                #97
                SO! I can write
                if(!MyIndex(MyIndex1).Value.ContainsValue(0)) return;
                ???

                I write this way
                if(!MyIndex("").Value.ContainsValue(0)) return;
                this variant without errors but the chart still the same as at the print-screen
                Last edited by alexstox; 04-04-2014, 03:14 PM.

                Comment


                  #98
                  Hello alexstox,

                  Please see my email that I sent you.
                  JCNinjaTrader Customer Service

                  Comment


                    #99
                    Dear JC, thank you very much for your support. Sorry, if I didn't change MyIndex1=""; to MyIndex1="MYINST";
                    Of course I had this in my script.
                    Did you get the same problem on your chart as I get? Please see print-screen in previous post.

                    The main question is how to set UPDW(MyIndex1) indicator to NOT do anything before first data of MyIndex1 will be available? My by default NT takes data from Master Instrument instead of not do anything?
                    Because of this in UPDW() indicator?
                    Values[0].Set(Input[0]-5*ATR(ATRbars)[0]);
                    So, how to fix that?!

                    Comment


                      As I understand the problem is because of Initialize() that plots indicator line and doesn't know any limitation. So, as solving I see only by not using Plot() for signal line, but using Draw().

                      Comment


                        Hello alexstox,

                        I do not get the same problem, but I believe the error is related. I get the following message when I try to test out your strategy "Error on calling 'OnBarUpdate' method for indicator 'MyIndex1' on bar 12: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.".

                        This is because you are calling an Indicator inside of another Indicator inside of your Strategy which is creating another cached instance of your "MyIndex1". You may want to rethinking your approach on this and either just use MyIndex1 as a visual representation and then when you want to access the Second Series Data in another Indicator, add it like you are doing inside of "MyIndex1".
                        JCNinjaTrader Customer Service

                        Comment


                          Let me explain

                          1. MyIndex("MSFT") indicator represent any instrument from NT - it just only for visualization in Strategy Analyzer.
                          2. UPDW(MyIndex("MSFT")) - another indicator that uses MyIndex("MSFT") data and draw some signals.
                          3. In my strategy I call for MyIndex("MSFT") for visualization and for UPDW(MyIndex("MSFT")) for signals.

                          Please explain your advise on this.

                          P.S. Wow! It's weird! I didn't have error with OnBarUpdate() before sending you example of scripts
                          And now I don't know what is wrong and how to fix
                          Last edited by alexstox; 04-08-2014, 03:56 PM.

                          Comment


                            Hello alexstox,

                            Using "MyIndex("MSFT")" for visualization is fine, but the item that you would want to stay away from is using the "UPDW(MyIndex("MSFT"))".

                            If you are wanting to have the "MSFT" Data inside of the "UPDW" indicator then you may just want to add it like you are doing inside of "MyIndex" instead of passing it the Indicator "MyIndex".

                            So it may look like "UPDW("MSFT")" this way your are adding the Data Series inside of an the Indicator instead of your other indicator.
                            JCNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by GwFutures1988, Today, 02:48 PM
                            1 response
                            5 views
                            0 likes
                            Last Post NinjaTrader_Clayton  
                            Started by ScottWalsh, 04-16-2024, 04:29 PM
                            6 responses
                            30 views
                            0 likes
                            Last Post ScottWalsh  
                            Started by frankthearm, Today, 09:08 AM
                            10 responses
                            36 views
                            0 likes
                            Last Post frankthearm  
                            Started by mmenigma, Today, 02:22 PM
                            1 response
                            3 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by NRITV, Today, 01:15 PM
                            2 responses
                            9 views
                            0 likes
                            Last Post NRITV
                            by NRITV
                             
                            Working...
                            X