Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

3 Points within 2 Bars

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

    3 Points within 2 Bars

    Hello guys,


    Need a suggestion please...

    Having 2 points Close[1] and Close[0] - it is easy to link them together with a simple line for instance.

    But if I have the following: Close[1] and Open[0] and Close[0]. There is a starting point on the last bar, but I have to choose 2 points on current bar, having a specific condition for them. Suppose I have to link them in a following sequence: Close[1], Close[0], Open[0].

    How can I define a that Close[0] is a priority point, rather then Open[0] within the same bar in order to link them with a simple line?


    Many thanks,
    Arthur

    #2
    Hi Arthur,

    Thank you for your post.

    I'm not sure if I'm following you correctly.

    What is the condition you are using for to choose between the two points?

    What is the purpose of the linking with a line?

    Do you have an example of what it is you are trying to accomplish?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hello Cal,


      Please find a picture attached.

      It could be any condition moving from point 1 to 2. Like on picture, it is:

      double MyPoint();
      if (Low[1] < Low[0])
      MyPoint = Low[0];

      But according to the points 2 and 3, how can I include point 3 to MyPoint data series? I assume it could be in this case:

      if (MyPoint == Low[0]) && (High[0] > Low[0])
      MyPoint = High[0];

      But the question is: Would all the points 1, 2 and 3 be remembered if I will draw a line graph using these data series or it will move directly from 1 to 3, ignoring point 2?

      Of course, there will be separate conditions for the cases, which are not included in this expression.


      Many thanks,
      Arthur
      Attached Files
      Last edited by FxInception; 12-16-2013, 11:49 AM.

      Comment


        #4
        Arthur,

        You could use the ELSE IF statement for the second condition. The first IF will take priority but its not true it will go to the ELSE IF next.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Arthur,

          You could use the ELSE IF statement for the second condition. The first IF will take priority but its not true it will go to the ELSE IF next.
          Yeah, but we are still talking about one point per bar, isn't it? I need to have both conditions to be true, but one before another within the same bar space.. Any other suggestions?

          Thank you,
          Arthur

          Comment


            #6
            Originally posted by FxInception View Post
            Yeah, but we are still talking about one point per bar, isn't it? I need to have both conditions to be true, but one before another within the same bar space.. Any other suggestions?

            Thank you,
            Arthur
            There seems to be a misunderstanding of a DataSeries as an entity. A DataSeries is a specific data structure, which stores values in a one-to-one correspondence with a barSeries, with exactly one, and only one, value for the DataSeries that corresponds to any single bar. You cannot have more than one value in a DataSeries that corresponds to any price bar.

            If you want to link points with lines, you just have to draw the linking lines. How you determine which points have priority will have to be coded by you as well.

            Comment


              #7
              Thanks Koganam, I've got it!


              Could you suggest then please what's wrong here?

              protected override void OnBarUpdate()
              {

              if (CurrentBar < 1)
              return;


              double WA;

              if ((Close[0] > High[1]) || (Close[0] < Low[1]))
              WA = Close[0];

              if ((Close[1] == WA) && (Close[0] == WA))
              DrawLine("MyLine", 1, Close[1], 0, Close[0], Color.Blue);


              It states: "Use of unassigned variable WA" and I have no idea why..


              Many thanks,
              Arthur

              Comment


                #8
                Originally posted by FxInception View Post
                Thanks Koganam, I've got it!


                Could you suggest then please what's wrong here?

                protected override void OnBarUpdate()
                {

                if (CurrentBar < 1)
                return;


                double WA;

                if ((Close[0] > High[1]) || (Close[0] < Low[1]))
                WA = Close[0];

                if ((Close[1] == WA) && (Close[0] == WA))
                DrawLine("MyLine", 1, Close[1], 0, Close[0], Color.Blue);


                It states: "Use of unassigned variable WA" and I have no idea why..


                Many thanks,
                Arthur
                Local variables must be assigned before they can be used. You have declared that the variable WA exists and that it is a double, but you have not assigned it any value.

                The reason this is illegal in C# is because using an unassigned local has high likelihood of being a bug. The compiler designers simply make it illegal; that way the compiler prevents you from ever having such a bug.

                Use
                Code:
                double WA = 0.0;
                instead.

                Comment


                  #9
                  Koganam you're an expert, could you tell me if it is possible to create an indicator that functions only as a linebreake and not everyone else? thanks

                  Comment


                    #10
                    Originally posted by mylanel View Post
                    Koganam you're an expert, could you tell me if it is possible to create an indicator that functions only as a linebreake and not everyone else? thanks
                    I am not quite sure what you are asking. Maybe you can show a picture?

                    Comment


                      #11
                      I created an indicator, and I wanted my indicator showed that for which 'was created only on a graph and linebreak does not work on other types of timeframe for example 5 minuts or 10 minuts
                      Attached Files
                      Last edited by mylanel; 12-17-2013, 04:25 AM.

                      Comment


                        #12
                        someone who knows the answer may respond, and because 'important.
                        thank you very much

                        Comment


                          #13
                          Thanks for the answer!


                          It compiles now, but for some reason I do not get any lines painted.

                          double WA = 0.0;

                          if ((Close[0] > High[1]) || (Close[0] < Low[1]))
                          WA = Close[0];

                          if ((Close[1] == WA) && (Close[0] == WA))
                          DrawLine("MyLine1", true, 1, Close[1], 0, Close[0], Color.Blue, DashStyle.Solid, 1);


                          Basically, if we get a higher high with close price above previous high - draw a line linking these 2 close prices (vice versa to lower low).

                          Apart from this issue, could someone suggest me please how to get a unique Tag each time the new drawing object occurs in order to not to repaint a previous one.


                          Thanks a lot,
                          Arthur

                          Comment


                            #14
                            Originally posted by FxInception View Post
                            Thanks for the answer!


                            It compiles now, but for some reason I do not get any lines painted.

                            double WA = 0.0;

                            if ((Close[0] > High[1]) || (Close[0] < Low[1]))
                            WA = Close[0];

                            if ((Close[1] == WA) && (Close[0] == WA))
                            DrawLine("MyLine1", true, 1, Close[1], 0, Close[0], Color.Blue, DashStyle.Solid, 1);


                            Basically, if we get a higher high with close price above previous high - draw a line linking these 2 close prices (vice versa to lower low).

                            Apart from this issue, could someone suggest me please how to get a unique Tag each time the new drawing object occurs in order to not to repaint a previous one.


                            Thanks a lot,
                            Arthur
                            What is the error in your log?

                            Comment


                              #15
                              These is no error in a log, just nothing paints...

                              Please find it attached if you would like to have a look.


                              Thanks,
                              Arthur
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

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