Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Builder, Fib drawing, set End Y at 50% between two bars

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

    #31
    Should I make a new request or keep going, for that and or else, higher or lower bar. But I'll continue tomorrow if stay here.

    Comment


      #32
      I'm not certain what you're asking - can you provide more details?

      If you're asking if you should create a new thread, it depends. We kindly ask that users create a new thread if your question is unrelated to your initial inquiry (the question you were initially asking).

      If your question is related to your initial inquiry, continue on this thread.

      Comment


        #33
        The next question is related to the initial inquiry (the question I initially was asking) so I'll ask it here.

        How would I state, draw from the highest of High[3] or High[2], 1, (Low[3] + High[1]) *0.5,
        These are my best guesses I know they are not correct.

        under the:

        else if (State == State.Configure)

        {
        if (High[2] > High[3] == true);
        (Low[2] > Low[3] == true);
        }

        Or a bool true or false under the public class SupportResistanceAndFibs : Strategy
        Last edited by trdninstyle; 10-24-2024, 05:33 PM.

        Comment


          #34
          Hello trdninstyle,

          To multiply using the '*' asterisk, there must be two values to multiply together.

          Where you have (* 0.5), this is attempting to multiply nothing by 0.5. (I don't mean you are multiplying by 0, I mean you have nothing before the asterisk. There is no value to multiply by 0.5)

          What are you wanting to multiple by 0.5?

          Try multiplying 1 by 0.5.

          (1 * 0.5)


          With the endY does not exist in the current context error, this is because no variable has been declared with the name endY.

          The overload parameters signature is:
          Draw.FibonacciRetracements(NinjaScriptBase owner, string tag, bool isAutoScale, int startBarsAgo, double startY, int endBarsAgo, double endY)

          The parameters you have supplied are:
          Draw.FibonacciRetracements(this, @"SupportResistance Fibonacci retracements_1", false, 3, 1, (High[3] + Low[1](* 0.5), double endY)
          .
          owner this
          tag @"SupportResistance Fibonacci retracements_1"
          isAutoScale false
          startBarsAgo 3
          startY 1
          endBarsAgo (High[3] + Low[1](* 0.5)
          endY double endY
          .
          Replace 'double endY' with the double value of the price of second anchor.
          Try using the High[0] to set the second anchor to the price of the high of the most recent bar.

          Note, you are using a price of 1 as the start anchor price.
          You are using '(High[3] + Low[1](* 0.5)' as the endBarsAgo which needs to be an integer (a whole number). Using a price as a barsAgo index does not make much sense.
          Further, you need to multiply something by 0.5. There must be some value there to multiply.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #35
            Hello Chelsea,

            Thank you for assisting me.

            This part of the code works as I wanted it to: The highlighted math here endY is catching the middle of the gap between 3 bars.
            (this, "SupportResistance Fibonacci retracements_1", false, 3, High[3], 1, (Low[3] + High[1]) *0.5, true, "AutoFib");


            This highlighted High[3] startY was what I wanted until I noticed sometimes High[2] can be higher than High[3] (outside bar)
            (this, "SupportResistance Fibonacci retracements_1", false, 3, High[3], 1, (Low[3] + High[1]) *0.5, true, "AutoFib");

            I would like for, the else if scenario to trigger startY to the higher of High[3] or High[2].

            Right now this is a single case scenario to my understanding.
            // Single case condition

            int x = 0;

            if (x == 0)

            {

            Print(NinjaTrader);

            }
            I would write it out along these lines ? else if (State == State.Configure)

            Comment


              #36
              Hello trdninstyle,

              I see you have modified the Draw.FibonacciRetracements() call and moved the '1' from the startY parameter to the endBarsAgo parameter, set the 'High[3]' to the startY parameter, are now multiplying (Low[3] + High[1]) by 0.5 as the endY value, and are now using the overload signature with the isGlobal and templateName parameters.


              "I would like for, the else if scenario to trigger startY to the higher of High[3] or High[2]."

              if (CurrentBar > 3)
              {
              Draw.FibonacciRetracements(this, "SupportResistance Fibonacci retracements_1", false, 3, Math.Max(High[3], High[2]), 1, (Low[3] + High[1]) *0.5, true, "AutoFib");
              }

              Chelsea B.NinjaTrader Customer Service

              Comment


                #37
                Thank you for that, where would the, if (CurrentBar > 3) go in relation to, if (Low[3] >= High[1]) ?

                Click image for larger version  Name:	2024-10-25 11_39_33-NinjaScript Editor - Strategy - SupportResistanceAndFibs.png Views:	0 Size:	12.9 KB ID:	1322680
                Last edited by trdninstyle; 10-25-2024, 09:43 AM.

                Comment


                  #38
                  Hello trdninstyle,

                  Any barsAgo index used must be equal to or less than CurrentBar.
                  The check was added to ensure there are at least 4 bars processed before using an index of [3].

                  "Thank you for that, where would the, if (CurrentBar > 3) go in relation to, if (Low[3] >= High[1])"

                  if (CurrentBar > 3)
                  {
                  if (Low[3] >= High[1])
                  {
                  // trigger some action
                  }
                  }
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #39
                    Thank you for that additional information, I placed it like this.

                    if (CurrentBar > 3)
                    {
                    if (Low[3] >= High[1]);

                    At the end of the draw object there's an expected notice.


                    Click image for larger version  Name:	2024-10-25 12_35_22-Chart - 5m ETH.png Views:	0 Size:	39.8 KB ID:	1322706
                    Click image for larger version  Name:	2024-10-25 12_49_23-NinjaScript Editor - Strategy - SupportResistanceAndFibs.png Views:	0 Size:	4.0 KB ID:	1322707

                    Comment


                      #40
                      Hello trdninstyle,

                      This is not what I have suggested in post # 36.

                      I've suggested:

                      if (CurrentBar > 3)
                      {
                      if (Low[3] >= High[1])
                      {
                      // trigger some action
                      }
                      }

                      You've put a semi colon after the nested if statement. Remove this.

                      An if statement needs either curly braces.
                      Add an opening an closing curly brace after the nested if statement.


                      What are you trying to do with this condition?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #41
                        I did add a semi colon & I removed it.

                        This part,

                        // trigger some action
                        }
                        }

                        I thought this was referring to the drawing. Both curly brackets are pointing the same direction? Then underneath that is my drawing object?

                        This has curly brackets

                        {
                        if (Low[3] >= High[1])
                        }

                        Do you mean add something more to this? { (Low[3] >= High[1]) } I know that don't seem right, I'm not understanding.

                        I'll show a pic of the situation I'm trying. This case yesterday was no gap but equal =
                        I drew these in by hand.

                        Click image for larger version  Name:	2024-10-25 13_48_04-Chart - 5m RTH.png Views:	0 Size:	12.2 KB ID:	1322717
                        Thank you for your patience.

                        Comment


                          #42
                          Hello trdninstyle,

                          In post # 37 you had not provided any context for what this condition is for.

                          You specifically asked how CurrentBar would be checked before this condition.

                          "I thought this was referring to the drawing."

                          I'm not seeing is relate to the drawing in your inquiry. I was assuming you were just adding further logic to the script and wanted to know how to check CurrentBar is greater than the barsAgo indexes used.

                          How is this related to the drawing?

                          Do you only want the drawing to only be initially drawn (or moved if already existing) when Low[3] is greater or equal to High[1]?

                          if (CurrentBar > 3 && Low[3] >= High[1])​
                          {
                          Draw.FibonacciRetracements(this, "SupportResistance Fibonacci retracements_1", false, 3, Math.Max(High[3], High[2]), 1, (Low[3] + High[1]) *0.5, true, "AutoFib");
                          }
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #43
                            Well, there was only (1) (2) (3) bars ago in the script. I made a rectangle to identify gaps between three bars, the low of bar (3) and the High of bar (1) if a gap it painted.
                            Opposite for the upside.

                            Click image for larger version

Name:	2024-10-25 14_21_39-Chart - 5m RTH.png
Views:	77
Size:	36.1 KB
ID:	1322725

                            The fib draws after the three bars measuring the high down to the center of that gap between the bars projecting 100% & 200%.
                            Just sometimes the bar in the middle can be a little higher than that 3rd bar.

                            By the time it prints as the current bar is going on, whatever bar is highest would be established.

                            It's usually not that much higher than bar (3) anyway.

                            Comment


                              #44
                              Chelsie, that worked.

                              if (CurrentBar > 3 && Low[3] >= High[1])
                              Math.Max(High[3], High[2]),

                              ..it draws from the highest of either bar 3 or bar 2 to the center of the gap in a three bar scenario.

                              Thank you very much.

                              I have this same strat in the Builder still, I was able to make it draw the rectangles only for longs or just the shorts then both, successfully by watching u-tube videos.
                              And I was able to shut on & off the fib drawing tool, thats very nice.

                              In the builder I want to create the option to color the rectangles any color but I can't find any u-tube videos showing this. I've been trying different things in builder to do this.

                              Could you or Gaby please assist me with this part?

                              Thanks guys.
                              Attached Files
                              Last edited by trdninstyle; 11-03-2024, 02:03 PM.

                              Comment


                                #45
                                The downside is working perfect but the upside only begins the draw from 3 bars ago when the 2 bars ago is lower than 3 bars ago.
                                Just to experiment, I put both Math.Max(Low[2], Low[2]), to see it, it drew from the lower 2 bars ago.

                                I place back the Math.Max(Low[3], Low[2]), and only draws from the 3 bars ago not the 2 bars ago, the lower low.



                                I couldn't fit, if (CurrentBar > 3 && Low[3] >= High[1]) in anywhere my first time w/out issues, so I left it out and only changed the Draw section and it works, for the downside.



                                Click image for larger version  Name:	2024-11-03 17_41_43-NinjaScript Editor - Strategy - SupportResistanceAndFibs.png Views:	0 Size:	6.3 KB ID:	1323565 Click image for larger version  Name:	2024-11-03 17_42_55-Chart - 5m RTH.png Views:	0 Size:	1.7 KB ID:	1323566

                                Comment

                                Latest Posts

                                Collapse

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