Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

To make a standard Fib setting as part of script

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

    #16
    "You've used the same tag name on both method calls, so the object will be updated instead of a new object drawn."
    Okay, I'll create a 2nd tag for that one.

    *********

    "The condition code I suggested, I was suggestion you could add to your existing condition."

    I see, after the initial 3 bars then, those conditions I want them to be ignored. Not colored.

    Would it be in my draw command then that I state to only color 3 bars?
    How can I cause it to stop coloring the 4th bar & more? I'm only stating bars 0, 1, and 2.

    When I first saw the BackBrush I thought maybe that was how we would cause it to un-paint the others or something. (I know its background)


    // Set 1 Strong Bull Case 3 Bar start of channel
    if ((Close[2] > Open[2] /*condition to start setting BarBrush*/ )
    && (Close[1] > Open[1])
    && (Close[0] > Open[0])
    && (Close[2] > High[3])
    && (Close[1] > High[2])
    && (Close[0] > High[1])
    && (Low[1] > Low[2])
    && (Low[0] > Low[1])

    && BarBrushes[3] != Brushes.Aquamarine)

    {

    BarBrushes[0] = MyBrush;
    BarBrushes[1] = MyBrush;
    BarBrushes[2] = MyBrush;
    }
    Last edited by trdninstyle; 11-29-2024, 08:57 AM.

    Comment


      #17
      Hello trdninstyle,

      BackBrush sets the color of the chart behind a bar.
      BarBrush sets the color of a bar.

      In the condition that assigns the BarBrush values, require in the condition that the counter variable is less than 4.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        In the condition that assigns the BarBrush values, require in the condition that the counter variable is less than 4.

        Do you mean these? Being the Barbrush values.

        && (Close[1] > Open[1])
        && (Close[0] > Open[0])
        && (Close[2] > High[3])
        && (Close[1] > High[2])
        && (Close[0] > High[1])
        && (Low[1] > Low[2])
        && (Low[0] > Low[1])

        && BarBrushes[3] != Brushes.Aquamarine)​

        If you mean these, how do I express this? Less than 4,
        && ...

        Or do you mean else if (counter = -1) but -4 not -1.

        or more like,
        if (counter >= 0 && == < 4)
        {

        }

        Comment


          #19
          Hello trdninstyle,

          When the condition is true, you want to color the next 3 bars that close in the future correct?



          Your condition would be setting the counter to 0.

          private int counter = -1;

          if ((Close[2] > Open[2] /*condition to start setting BarBrush*/ )
          && (Close[1] > Open[1])
          && (Close[0] > Open[0])
          && (Close[2] > High[3])
          && (Close[1] > High[2])
          && (Close[0] > High[1])
          && (Low[1] > Low[2])
          && (Low[0] > Low[1])
          && BarBrushes[3] != Brushes.Aquamarine)​
          {
          counter = 0;
          }

          if (counter >= 0 && counter < 3)
          {
          BarBrushes[0] = MyBrush;
          BarBrushes[1] = MyBrush;
          BarBrushes[2] = MyBrush;​
          counter++;
          }
          else if (counter == 3)
          {
          counter = -1;
          }​
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Actually the condition paints the 3 bars after it happens, after 3 closes. By painting those 3 bars it makes the trader aware of the condition which has over a 90% chance for a 2nd leg after a pull back, sometimes no pull back, A=C, B wave is the pb.

            It takes 3 bars in this condition for the start of a micro channel, I don't want bars in the future pained just the 3 bars that just printed, but no more bars painted after the initial 3 bars.

            How about setting the counter to 3 bars ago? Not 0. After the condition has happened, having it to 0, would start counting after the 3 bars has happened, 0, 1, 2.

            Thanks for helping me on this Chelsea
            Last edited by trdninstyle; 11-29-2024, 11:35 AM.

            Comment


              #21
              Hello trdninstyle,

              The suggested code was for triggering the action on the next 3 bars where it continues..

              "You see, I'm calling it to color the first 3 bars when certain conditions apply, but when those conditions continue for a bar or more it colors those too.
              I'm wanting to just BarBrush the first 3 bars & no more.​"

              If you are just wanting to set the brush of the last 3 bars when the condition is true, your original code should be fine and no counter would be needed.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                "..but when those conditions continue for a bar or more it colors those too." "I'm wanting to just BarBrush the first 3 bars & no more."
                Sorry, I was explaining that it does continue but I don't want it to. To make it stop coloring bars after 3 bars.



                "If you are just wanting to set the brush of the last 3 bars when the condition is true, your original code should be fine and no counter would be needed."

                But it doesn't stop at 3 bars though with the original script, it keeps painting them if the 4th or 5th bar has a close above the prior high & those lows are higher than prior lows.
                It will paint many bars in a row when conditions persist, I only want the first 3 bars even if there are 20 bars in a row, would be rare.




                Comment


                  #23
                  Hello trdninstyle,

                  I feel there is a different between "stop coloring bars after 3 bars" and 'color the last 3 bars'..

                  Stop color after 3 bars I feel implies that on each bar update color the bar and then stop after 3 bars have updated. This would be color each future bar as it comes in.

                  Coloring the last 3 bars would mean on the current bar, color the last 3 bars in the past..


                  "But it doesn't stop at 3 bars though with the original script, it keeps painting them if the 4th or 5th bar has a close above the prior high & those lows are higher than prior lows."

                  Setting the last 3 bars color in the past would happen any time the condition is true.

                  As a bar updates, the condition would color the last 3 bars.

                  Do you want the condition to not be true if the condition was true in the last 3 bars?

                  Do you want the condition to be true once and then never again?

                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    Yes thats what it's doing, it continues as the condition continues. "Setting the last 3 bars color in the past would happen any time the condition is true."

                    "Do you want the condition to be true once and then never again?"
                    I want it to only be true on the first 3 bars but then ignore or cut it off if it continues to be true. Tell it to revert back and only count the first 3 bars, only highlight the first 3.

                    Comment


                      #25
                      Hello trdninstyle,

                      If you want the condition to only be true once and never reset, then use a bool.

                      private bool actionOccurred;

                      if (actionOccurred == false /* && conditions to trigger action */)
                      {
                      // trigger actions such as setting the BarBrushes of the last 3 bars
                      actionOccurred = true;
                      }
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #26
                        Did I do this 100% correctly?

                        Click image for larger version  Name:	2024-11-29 13_33_25-To make a standard Fib setting as part of script - NinjaTrader Support Forum - D.png Views:	0 Size:	67.4 KB ID:	1326163 Click image for larger version  Name:	2024-11-29 13_33_46-NinjaScript Editor - Strategy - ThreeBarSequence.png Views:	0 Size:	41.0 KB ID:	1326164


                        I made sure to remove the counter material. Don't believe I did it right.

                        Hold on I see it. I'll remove that other part.

                        I was mistaken, I seen this.. and thought I still left something from the counter.

                        if (CurrentBars[0] < 3)
                        return;
                        Last edited by trdninstyle; 11-29-2024, 12:43 PM.

                        Comment


                          #27
                          Hello trdninstyle,

                          The commented out part /* && conditions to trigger action */ is where you conditions that trigger the action go.

                          The bool needs to be set to true in the logic block.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #28
                            I'm not understanding where to place the.. if (actionOccurred == false




                            I believe I have this part right..
                            {
                            actionOccurred = true;
                            BarBrushes[0] = MyBrush;
                            BarBrushes[1] = MyBrush;
                            BarBrushes[2] = MyBrush;
                            }

                            Click image for larger version

Name:	2024-11-29 14_37_02-2024_11_29_14_35_24_To_make_a_standard_Fib_setting_as_part_of_script_NinjaTrader.png
Views:	85
Size:	54.2 KB
ID:	1326185
                            Last edited by trdninstyle; 11-29-2024, 01:37 PM.

                            Comment


                              #29
                              Hello trdninstyle,

                              This is a condition that goes in a branching command.

                              Your branching command.

                              if (actionOccurred == false
                              && (Close[2] > Open[2])
                              && (Close[1] > Open[1])
                              && (Close[0] > Open[0])
                              && (Close[2] > High[3])
                              && (Close[1] > High[2])
                              && (Close[0] > High[1])
                              && (Low[1] > Low[2])
                              && (Low[0] > Low[1])
                              && BarBrushes[3] != Brushes.Aquamarine)​
                              {

                              }​
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                This is much closer and I have the private bool actionOccurred; above.

                                It compiled but it didnt paint any bars.

                                Click image for larger version

Name:	2024-11-29 15_01_08-To make a standard Fib setting as part of script - NinjaTrader Support Forum - D.png
Views:	87
Size:	52.4 KB
ID:	1326192

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                70 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                143 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                76 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                47 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                51 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X