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

    #31
    Hello trdninstyle,

    Use prints to understand why.


    Start by printing the bar time and a label (for example 'condition true') from within the logic block (where the barbrushes are being assigned and the bool is being assigned).
    Chelsea B.NinjaTrader Customer Service

    Comment


      #32
      Okay, I'll read over all that to learn how to use prints, so I did place all of the items into the correct places now? Thank you.

      Comment


        #33
        Hello trdninstyle,

        Yes, the condition and action appear correct.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          We got it Chelsea!

          I ran experiments across the board then the last one I commented out // actionOccurred = true;

          {
          // actionOccurred = true;
          BarBrushes[0] = MyBrush;
          BarBrushes[1] = MyBrush;
          BarBrushes[2] = MyBrush;
          }

          Very good and I thank you Sir once again I so much appreciate your patience and professionalism. I don't have to learn debugging using print just yet.


          Click image for larger version

Name:	2024-11-29 19_32_50-Chart - 5m ETH.png
Views:	112
Size:	46.8 KB
ID:	1326213 Click image for larger version

Name:	2024-11-29 19_34_25-Chart - 5m ETH.png
Views:	106
Size:	33.5 KB
ID:	1326214 Click image for larger version

Name:	2024-11-29 19_33_44-NinjaScript Editor - Strategy - MyCustomStrategy1.png
Views:	103
Size:	82.8 KB
ID:	1326215 ​

          Comment


            #35
            Hello trdninstyle,

            Debugging is one of the most important aspects of programming (in any language for any application).

            If you are not familiar with debugging, I recommend you stop what you are doing, and learn to do this first.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #36
              Okay, I guess I better. I went through the steps once before a long time ago. I wish there was a video of going through the steps right up to the end, I'll probably make one later.
              I use troubleshooting technique's I learned as an electrician.

              Only the 3 bars color now as I wanted, I added a few more wrinkles that works fine now too, but when I change colors it colors more than the 3 bars until I reset the default, my default colors come back with just the 3 bars being filled in.

              The fibs calculate from the 1st 3 bars but then again from the next 3 bars giving me two projected levels. I'm going to want to have just the 1st 3 bars only & try to eliminate the 2nd reading.
              Click image for larger version

Name:	2024-12-02 09_26_18-Chart - 5m ETH.png
Views:	106
Size:	36.2 KB
ID:	1326323
              Then I change the colors from the interface..
              Click image for larger version

Name:	2024-12-02 09_28_17-Chart - 5m ETH.png
Views:	99
Size:	48.6 KB
ID:	1326324
              Even when I place back original colors thats not enough, I have to reset the default for it to do so.

              Click image for larger version

Name:	2024-12-02 09_30_35-NinjaScript Editor - Strategy - ChannelSequence.png
Views:	101
Size:	60.4 KB
ID:	1326325 Click image for larger version

Name:	2024-12-02 09_32_01-NinjaScript Editor - Strategy - ChannelSequence.png
Views:	104
Size:	26.5 KB
ID:	1326326
              I'll start learning prints today now.

              Comment


                #37
                I made a separate copy for debugging it has only the channel up.


                "Start by printing the bar time and a label (for example 'condition true') from within the logic block (where the barbrushes are being assigned and the bool is being assigned)."

                I pasted in the sample here but what would it look like putting in bar time and label, condition true? Also, being that once I change colors it loses that action to color only 3 bars, what would I put in to address that?

                I have the output window up when does the information come across? When I compile?

                Click image for larger version

Name:	2024-12-02 13_00_56-Chart - 5m ETH.png
Views:	111
Size:	58.3 KB
ID:	1326353 Click image for larger version

Name:	2024-12-02 13_01_24-Chart - 5m ETH.png
Views:	96
Size:	20.9 KB
ID:	1326354

                Comment


                  #38
                  Hello trdninstyle,

                  You have not added that print to the logic block for the branching command that also sets the BackBrushes.

                  You have instead made a new branching command and added the print to the logic block for that new branching command.

                  Note, a basic understanding of C# programming is prerequisite to writing NinjaScript code.
                  Below is a link to a support article with helpful resources on getting started with C# and NinjaScript.



                  "I pasted in the sample here but what would it look like putting in bar time and label, condition true?"

                  Below is a link to a support article on using prints to understand behavior.


                  Following the sample code from the support article this would appear as:
                  Print(string.Format("{0} | condition true", Time[0]));


                  "Also, being that once I change colors it loses that action to color only 3 bars, what would I put in to address that?"

                  Outside of the condition set, print all of the variables and values compared in the condition.

                  This is demonstrated in the 'NinjaScript Editor 401' video linked from the article.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #39
                    I corrected that the print is now in the logic block for the branching command. Thanks for showing me how to type that print in, I'll go over all of those links and especially that video 401 editing.

                    I had to keep actionOccurred = true; comment out from the logic block because nothing comes from it. But with that out I get a printout of whats happening, on the 2nd printout after changing colors it just informs me at what time it took place. It's the trace orders that will allow me to dive deeper right? As to why it continues to color bars & that I have to reset default to make it work.

                    I'll go over everything you just sent me & I'll learn more though. I made a one day look back on chart to limit printouts.

                    Click image for larger version

Name:	2024-12-02 13_59_20-Chart - 5m ETH.png
Views:	101
Size:	50.6 KB
ID:	1326370 Click image for larger version

Name:	2024-12-02 13_59_59-NinjaScript Editor - Strategy - ChannelSeqDebugging.png
Views:	94
Size:	30.2 KB
ID:	1326371

                    Comment


                      #40
                      Hello trdninstyle,

                      TraceOrders provides information about orders being submitted, ignored, rejected, or automatically cancelled. The code you have provided does not show any order methods being called.

                      To dive deeper print the values compared in the conditions with labels for each value and comparison operator. This print should be outside of the branching command (one line above)

                      The actionOccurred being set to true was at your request.

                      Post # 24:
                      ""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.​

                      Post # 25 (my reply):
                      "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


                        #41
                        Thank you, I assume I did this correctly, one line above the branching command.

                        Click image for larger version  Name:	2024-12-02 15_09_16-NinjaScript Editor - Strategy - ChannelSeqDebugging.png Views:	0 Size:	33.8 KB ID:	1326383

                        I did comment out the print & did one without commenting it out. All it is saying now is "condition true "for every 5 minutes which it should say that I guess since it's before the conditions.

                        ya as far as what I said, I just wanted 3 bars painted even if there are 4 to 5 bars in a row with the same condition, just paint the first 3. What you told me worked except for that last item. I appreciate ya. Now why doesnt it work after changing colors? I'm trying to get there and youre helping.

                        "If you want the condition to only be true once and never reset, then use a bool."
                        Another words, if 5 bars in a row have the same condition paint the first 3 bars and not more. Perhaps there's another way to say this in the script? I don't know.

                        I'm thinking that this.., if ((actionOccurred == false/* && conditions to trigger action*/) is only telling.., && BarBrushes[3] != Brushes.Aquamarine) to paint just 3 bars when there's more.

                        That, && BarBrushes[3] != Brushes.Aquamarine) needs to expand beyond Brushes.Aquamarine but all of the colors or cover that section that changes the colors. But how? I don't know.

                        When I move outside of Brushes.Aquamarine it's just doing what I'm programing it to do.
                        Last edited by trdninstyle; 12-02-2024, 02:49 PM.

                        Comment


                          #42
                          Hello ,

                          "ya as far as what I said, I just wanted 3 bars painted even if there are 4 to 5 bars in a row with the same condition, just paint the first 3."

                          This would do that. As after the condition is true, it will never paint any futures bars again. If there are 4 or 5 or in a row, or even if it's true on a bar 1000 bars later the condition will never be true again.

                          The actions from the condition should only occur once.

                          "Another words, if 5 bars in a row have the same condition paint the first 3 bars and not more. Perhaps there's another way to say this in the script? I don't know."

                          This will be achieved as it will only occur once and will not occur for any future bars.


                          The check for actionOccurred == false condition in the branching command is to prevent the branching command from evaluating as true after the bool has been assigned a value of true in the logic block (when the branching command first evaluates as true).

                          This is to prevent the action from occurring a second time.


                          Note, in post # 23, I was asking you when you want to reset and allow the condition to be true again. This information was not provided so I assume you don't want the condition to ever be true again.

                          "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


                            #43
                            Hello Chelsea,

                            I went over all of that material, I learned a few things it was pretty good.

                            I put back the actionOccurred = true; in the logic because I figured it's part of that whole thing & to find out what is happening when I do place it in there.

                            I know what's going on! It's doing just what we told it to do, to find it once and not again, ever again lol. Finds it once on a ten day look back then once on a 20 day look back. I never bothered to look for it in the beginning of my lookback so I assumed the actionOccured = true wasn't working, it is working. It works too good.

                            Well, running the print turned out to be a good thing.

                            Also, I bet if there was 4 or 5 bars in a row it would have just colored 3 bars.







                            Click image for larger version  Name:	2024-12-03 12_28_58-Chart - 5m ETH.png Views:	0 Size:	51.1 KB ID:	1326471 Click image for larger version  Name:	2024-12-03 12_30_58-NinjaScript Editor - Strategy - ChannelSeqDebugging.png Views:	0 Size:	35.3 KB ID:	1326472

                            Click image for larger version  Name:	2024-12-03 12_50_02-Chart - 5m ETH.png Views:	0 Size:	56.3 KB ID:	1326473
                            Last edited by trdninstyle; 12-03-2024, 12:04 PM.

                            Comment


                              #44
                              Hello trdninstyle,

                              If you do ever want to reset the bool back to false so the object can be drawn again, do this in different branching command.
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #45
                                The bool is at false, I never changed it to true, in the branching command. Just now I changed it to true in the branching command but nothing happens. When I change actionOccured to false (logic) it's just like when I comment it out, it paints 3 bars but also more bars when the condition continues.

                                Maybe what you suggested to me went over my head, if I want to change it back to false do so in another branching command. But it's still at false.


                                if ((actionOccurred ==false/* && conditions to trigger action*/)
                                actionOccurred = true

                                This is too stringent, is there a way to have it reset after each time? within each day.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                71 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