Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multi-time frame beginner

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

    #31
    Thanks. I think you are telling me that a variable, once assigned, will be recognized in either primary or secondary charts. This is good news but I having trouble using that capability.

    In the test program I have uploaded, if the bottom comments are uncommented, it will not compile. I get an error message "semicoln expected after if(Close[0] > bp"

    Hopefully you could tell me what I am doing wrong. (The primary chart is 1 minute)
    Attached Files

    Comment


      #32
      Hello,

      Thank you for the reply.

      Yes, in this case the variable can be used in both bar contexts because in reality they are in the same method.

      Looking at where you have defined the variable in contrast to its use will show how it can be used:

      Code:
      private double bp = 50;
      
      protected override void OnBarUpdate()
      {
      
      }
      Because this is declared outside of OnBarUpdate, all the code inside of OnBarUpdate would have access to the variable bp.

      The reason for the error is simply a casing issue, you have a capital I in the if statement, this just needs to be lowercase.

      Code:
      [B]I[/B]f(Close[0] > bp)
      instead would be
      Code:
      [B]i[/B]f(Close[0] > bp)
      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #33
        Thank you for pointing out that mistake.

        I would prefer using CrossAbove() to avoid repeated alarms, but keep getting error "Argument 2 cannot convert from 'double' to Data iDataseries"

        Though Ninja Help clearly shows that a value can be used as argument 2.
        "Top1" is a variable that has a value.

        if(BarsInProgress == 0)
        {
        if(CrossAbove(Close[0], Top1, 1))
        {
        PlaySound(SoundFileName);
        }
        }

        Comment


          #34
          Hello,

          In this case you are trying to compare two Double numbers in the CrossAbove, but it only can take 1 double number and 1 iDataseries.

          The reason you are getting this is the BarsAgo that is appended to the Close. When you see something in the helpguide that lists iDataseries or an error like this you can know that you need the whole Series rather than just 1 value of 1 bar.

          Close[0] would be the Close price of 0 bars ago (1 bar) where the Close without [0] signifies the entire series. This method just wants the entire series instead of just two values.

          Assuming Top1 is a double variable, the syntax should instead be:

          Code:
          CrossAbove(Close, Top1, 1)
          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #35
            Muilt time frame

            Hi,
            I have a 5 min chart and 10 min chart together , I have macd on 10 min chat, looking to read when 10 macd > 0 and to add it in my indicator that on the 5 min chart
            Thanks

            Comment


              #36
              Hello,

              Thank you for the post.

              To better understand multi timeframe scripts I would suggest to review the following items. If you need further assistance at that point, I would suggest to create a new thread for your specific questions as this question is not specifically related to the OP's post.





              These items would help you in exploring multi series scripts, additionally you could review the Strategy SampleMultiTimeFrame or SampleMultiInstrument for a working example.


              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #37
                Ok thanks for the info

                Comment


                  #38
                  I am now trying to convert my little program to Ninja 8. I am getting the following error message in the output window:

                  "Indicator 'Range45': Error on calling 'OnBarUpdate' method on bar 314: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

                  Can you see what they are talking about? I am attaching the program what I have done so far. It compiles OK but doesn't work. It did work fine in Ninja 7.
                  Attached Files
                  Last edited by Pete77; 11-28-2016, 08:04 PM.

                  Comment


                    #39
                    Hello,

                    Thank you for the post.

                    I tried the script but instead got the error on bar -1, this could potentially be the Times[1][-1] line, negative or future indexes generally should not be used as there is no data received for the future. If you had instead intended 1 BarsAgo, it would be a positive 1 or:
                    Times[1][1]

                    I see when commenting out the Draw.Line syntax the error goes away for me.

                    For this, because there are few lines of code it would be easiest for you to see which specific line is causing the error. To do this you could just comment all the lines out, try the script, and then uncomment them one at a time and try the script with each compile.
                    When you locate the line in error, you would receive the error again to know which line is the cause.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #40
                      Thanks, you were right, the [1][-1] on the DrawLine and DrawRectangle lines is what caused the error. It is now working with Times [1][1]except the dotted line and rectangles are not
                      repeating with the new calculations as each 45 minute bar terminates (as it did in Ninja 7 using Times [1][-1]).
                      I will try to figure this out

                      Comment


                        #41
                        I am still trying to convert my little program to work in Ninja 8 but I am stuck.

                        My Draw.Line and Draw.Rectangle statements that work in Ninja 7 do not work in Ninja 8. For example:

                        "DrawLine("mytag" + CurrentBar, true, Times [1][0], bp, Times[1][-1], bp, Color.White,
                        DashStyle.Dot, 3);"

                        Times[1][-1] defines the right hand of objects in Ninja 7 (the width of the underlying 45 minute bar) before the object comes fully into view (see attached) but it gets an error in Ninja 8. You will see in the attached that the current line and rectangles are only half visible.

                        There must be a way to define an object in Ninja 8 before it has all come into view but I have exhausted all efforts. Can you help me with this?
                        Last edited by Pete77; 12-02-2016, 03:16 PM.

                        Comment


                          #42
                          Hello,

                          Thank you for the reply.

                          In general negative indexing was not supported in NT7 and still is not, although in some cases it is possible to use negatives it is not suggested.

                          I am unable to see what you have mentioned that you attached, but it sounds like potentially you are trying to size the object to match the edge of the bar, is this correct? Could you attach an image of the desired effect?

                          I look forward to being of further assistance.
                          JesseNinjaTrader Customer Service

                          Comment


                            #43
                            I will try to explain. My primary series is 3 minute, secondary is 45 minutes. The dotted line is high + low + close of the previous 45 minute bar. The rectangle pairs calculated from the dotted line form price ranges. All calculations are done in the "if(BarsInProgress == 1)" area at the time each 45 minute rectangle (and dotted line) terminates.

                            I will try again to attach a sample from Ninja 7.

                            As mentioned before the statement DrawLine("mytag" + CurrentBar, true, Times [1][0], bp, Times[1][-1], bp, Color.White, DashStyle.Dot, 3);

                            works in Ninja 7 but not in Ninja 8.
                            Attached Files
                            Last edited by Pete77; 12-06-2016, 02:09 PM.

                            Comment


                              #44
                              Hello,

                              Thank you for the post.

                              In the image are we looking at the rightmost two rectangles that extend beyond the charts edge? Is this the effect that you are trying to achieve? If so are you trying to achieve a drawing object that extends beyond the current bar or only to the edge of the charts panel?

                              I look forward to being of further assistance.
                              JesseNinjaTrader Customer Service

                              Comment


                                #45
                                Thanks for the reply.

                                The length of the dotted line (Balance point) and rectangles (that establish 45 minute price ranges) mirror each 45 minute bar in the secondary series below. Or to more exact the distance from one 45 minute bar edge to the next same bar edge. The lines are drawn in the secondary series and show up in the primary. The margin has nothing to do with them.

                                I will attach a stripped down version of my program. The length of the dotted line will be exactly the same as the rectangles would have been and calculations thereof that I have omitted.

                                As mentioned previously the program is working fine in Ninja 7 I am hoping for some help in converting it to work n Ninja 8.
                                Attached Files
                                Last edited by Pete77; 12-09-2016, 08:30 AM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Waxavi, Today, 02:10 AM
                                0 responses
                                6 views
                                0 likes
                                Last Post Waxavi
                                by Waxavi
                                 
                                Started by TradeForge, Today, 02:09 AM
                                0 responses
                                11 views
                                0 likes
                                Last Post TradeForge  
                                Started by Waxavi, Today, 02:00 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post Waxavi
                                by Waxavi
                                 
                                Started by elirion, Today, 01:36 AM
                                0 responses
                                4 views
                                0 likes
                                Last Post elirion
                                by elirion
                                 
                                Started by gentlebenthebear, Today, 01:30 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post gentlebenthebear  
                                Working...
                                X