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

NinjaScript Drawing Objects Not Drawing

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

    NinjaScript Drawing Objects Not Drawing

    Hello,

    This is in regards to the NinjaScript NT8 indicator that I created yesterday, it is not behaving as intended. My original post is here:

    Hello, I'm trying to create an indicator (starting from the Strategy Builder), that will give me a signal when the following exists: * Current 15 minute


    Regarding this NinjaScript NT8 indicator that I created yesterday, it has not yet once drawn a triangle on the chart when it was supposed to, and I discovered one reason why, which is that I was asking for it to act only after ALL CONDITIONS had been met (15 minute chart, 60 minute chart, daily chart, weekly chart AND monthly chart conditions).

    So I changed to code to draw a triangle if EITHER CONDITION was met, then tested it again, but still, it has not yet once drawn a triangle on the chart when it was supposed to.

    Then I tried changing the Drawing Object code and tested it again, but still, it is not drawing a triangle on the chart.

    Attached are screenshots of the code and the changes that I made.

    The black arrows that I drew on the chart screenshot show where an arrow should have been drawn.

    Attached also is a zip file with the new version of the indicator.

    Please advise.
    Attached Files

    #2
    Hello i2w8am9ii2,
    Thanks for your post.


    What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 7.0.1000.X or 8.0.X.X)

    Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

    If you add a Print() inside the condition do you see it becoming true?

    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Thanks for your reply.

      I am using Ninjatrader version 8.0.15.1 64-bit

      I only see one message in the Control Center log tab that (in my opinion) could be considered an error, and it says: "Ease of movement relies on volume updates expecting Calculate 'On each tick' or 'On bar close'

      I don't know what this is referring to, as I do not have any Ease of Movement indicator on my charts. And the only volume indicator that I have on my charts is the 'Volume up down' indicator, and it is set to calculate on each tick.

      I have not added a Print() code inside the condition, as I figured that right-clicking on the chart and going into Drawing Tools > Drawing Objects... would let me know if a triangle was being drawn or not.

      What do you suggest?

      Comment


        #4
        Hi Josh,

        I just added the Print() code inside the condition and so far, nothing has appeared in the NinjaScript Output windows.

        Screenshots attached.

        Did I write the Print() code correctly? It did compile without errors.

        Comment


          #5
          I don't believe the "ease of movement'" error is the issue here.

          I have found that the most effective way to go about troubleshooting these types of things is to add a Print() inside each condition and watch my charts for the condition to become true. If you never see the print then your condition never became true (and would never draw your triangle).

          Another thing that helps with things like this is creating an extremely simple condition (ie. Close[0]>Open[0]) and watching to see if your drawing object gets placed on the chart. If it does not then I would expect an error on the logs tab or the wrong input parameters.

          Since your parameters look correct I suggest simplification of your condition. I would start by comparing one series at a time and then adding your further conditions to see where the issue lies.
          Josh G.NinjaTrader Customer Service

          Comment


            #6
            Hi Josh,

            Thanks for the reply.

            I did test using a Print() inside the two Draw Objects condition, but I'm not sure if I wrote the code correctly.

            Nothing appeared in the NinjaScript Output windows while using this Print() code in Playback mode (I used Playback mode so that I could speed up the formation of new 15 minute bars).

            Screenshot of the Print() code that I used is attached.

            Please let me know if this Print() code is correct or not.
            Attached Files

            Comment


              #7

              If you do not see a print and there is no error than your condition did not become true.

              Do you see the triangle if you only compare the 15 minute series like the snippet below?
              Code:
              if(Closes[6][0]>Closes[6][1])
              {
                  Draw.TriangleUp(this,"myTag310",true,0,Close[0]-TickSize,Brushes.Blue);
              }
              Last edited by NinjaTrader_JoshG; 10-12-2018, 01:55 PM.
              Josh G.NinjaTrader Customer Service

              Comment


                #8
                Hi Josh,

                Thanks for your suggestion and code.

                First I tried moving the Print() code above the Draw.TriangleUp and Draw.TriangleDown commands, and ran that test, but there was nothing on the NinjaScript Output windows again and nothing when checking Drawing Tools > Drawing Objects...

                So then I commented out my code and tried the code you gave me. At first I got a couple of errors, I think because the code had 'Closes[0]', not 'Close[0], so I changed it to 'Close[0]' instead and was able to compile it.

                Then I did the test in Playback mode and still got nothing on the NinjaScript Output windows and nothing when checking Drawing Tools > Drawing Objects...

                Screenshots attached.

                Comment


                  #9
                  Your condition simply is not becoming true. You need to simplify this down.

                  I suggest removing the added data series' and starting with a single time frame. Working with multi-time frames requires different considerations that must be followed. I suggest starting with the smaller time frame(15min) and then adding the larger time frames as you build your logic. You will want to start by removing
                  Code:
                  if(BarsInProgress!=0)
                  return;
                  Please see the following link for more information on working with multiple time frames:
                  https://ninjatrader.com/support/help...nstruments.htm

                  For starters, try testing this snippet. This is going to draw an up triangle using a single time frame every time the Close[0]>Close[1]
                  Code:
                  protected override void OnBarUpdate()
                  {
                      if(CurrentBar<1) return;
                      if(Close[0]>Close[1])
                      {
                          Draw.TriangleUp(this,"myTag"+CurrentBar,true,0,High[0]+TickSize,Brushes.Red);
                      }
                  }
                  Josh G.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Josh,

                    Thanks for the info and for the code.

                    I will test it out.

                    Attached is a screenshot of the change that I made in the code, to test long and short trades.

                    Please let me know if you see an error anywhere in this code change on the long or short side.

                    Thanks again,

                    Comment


                      #11
                      Hi Josh,

                      I think I discovered the problem.

                      I created a new copy of the indicator, then went to my charts to remove the first version and to add the new version, then I noticed that I had it set to 'Calculate on price change'.

                      So I changed it to 'Calculate on each tick' and then a ton of arrows showed up on my chart.

                      Screenshot attached.

                      I will need to test if this change will also work with the original version of the indicator, if I use all the different time-frames that I had initially.

                      I will let you know the results of my testing.

                      Comment


                        #12
                        Hi Josh,

                        The test with the multiple time-frames with my original version of the indicator did not draw any arrows, after changing it to 'Calculate on each tick'.

                        So it appears that it was the new code you gave me to test that made the arrows get drawn, and not the change of the 'Calculate' setting.

                        Comment


                          #13
                          Hello Josh,

                          I got it to work with two time-frames, the 15 minute and 30 minute, but it does not work when trying to use any other time-frames in addition to those.

                          I ended up reversing the order of the indexes, not sure if that has anything to do with it working or being limited.

                          I will test reversing the order of the indexes back again.

                          Screenshots attached.

                          By the way, I do get an error on the NinjaScript Output window. Screenshot of that is attached also.

                          Comment


                            #14
                            Hello i2w8am9ii2,

                            To confirm, once the script has run, there isn't a single drawing object appearing the Chart > right-click menu > DrawObjects window?

                            The script you have shown a screenshot of shows two different objects types trying to use the same tag name. This is not allowed.
                            You will need to use unique tag names.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Chelsea,

                              Thanks for your follow up.

                              The arrows are being drawn on the chart, only if I use a maximum of two time-frames (15 minute and 30 minute).

                              Screenshot attached.

                              And the Draw Objects window does show my tag for the arrows.

                              But what happens is that when I only have the 15 minute time-frame as a condition, then there are countless arrows that get drawn on the chart. But when I add the 30 minute time-frame as a second condition, then I just get one or two arrows drawn on my charts.

                              That is causing me to believe that the || operators are telling Ninjatrader to only look for the condition on the 15 minute time-frame "OR" on the 30 minute time-frame and to ignore any instances when the condition is present on both time-frames. So it would kind of be acting like an && condition, in a way. That is my theory, not sure if that is possible or not.

                              That would also explain why when I add a 60 minute time-frame, all the arrows disappear. And that when I add a daily, weekly or monthly time-frame, there are no arrows.

                              Is there a way to say AND/OR (&& ||) in this script? If so, what would that code look like?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RookieTrader, Today, 09:37 AM
                              3 responses
                              15 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by kulwinder73, Today, 10:31 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post kulwinder73  
                              Started by terofs, Yesterday, 04:18 PM
                              1 response
                              23 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by CommonWhale, Today, 09:55 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by Gerik, Today, 09:40 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Gerik
                              by Gerik
                               
                              Working...
                              X