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

Draw a dot every 60 seconds

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

    #16
    Jumper, correct there would be a DrawLine and also a DrawHorizontalLine method (would extend) -





    Important is the used tag id for your draw method call in general, so if you reuse an older tag > it will just update the object for you - where as if a new unique tag is used a new object would be created.

    I'm not sure which CalculateOnBarClose setting you use, but generally the FirstTickOfBar would be good to catch the opening / closing of the candle as event.
    BertrandNinjaTrader Customer Service

    Comment


      #17
      Thanks for the reply! Can you explain a little more? Not sure I understand the tag ID thing, and how I put all this together, so I take it I have something like this in my OnBarUpdate section?

      if (FirstTickOfBar)
      {
      DrawHorizontalLine(???? Not sure what to put here? noOfLines variable, and DistanceApart variable);
      }

      Where do I set how many ticks above and below FirstTickOfBar the horizontal line is drawn?
      Last edited by Jumper; 07-28-2014, 03:02 AM.

      Comment


        #18
        Jumper, you will want specify an y axis value to draw the line at, i.e. Open[0] +- TickSize

        For the tag id's you assign, best example to check into would be this one - http://www.ninjatrader.com/support/f...ead.php?t=3419
        BertrandNinjaTrader Customer Service

        Comment


          #19
          Originally posted by NinjaTrader_Bertrand View Post
          Jumper, you will want specify an y axis value to draw the line at, i.e. Open[0] +- TickSize

          For the tag id's you assign, best example to check into would be this one - http://www.ninjatrader.com/support/f...ead.php?t=3419
          Where do I put that Open[0] +- TickSize bit though, inside my DrawHorizontalLine()?

          Also the if (FirstTickOfBar) won't work as it will be false most of the time, it won't draw previous bars lines?

          I don't understand the DrawHorizontalLine method, to me it would make sense to have:

          if(FirstTickOfBar)
          {
          DrawHorizontalLine("Line" + CurrentBar, Open[0] + TickSize);
          DrawHorizontalLine("Line1" + CurrentBar, Open[0] - TickSize);
          }

          But the DrawHorizontalLine method wants all these arguments that I don't understand, and keeps giving me errors.

          Also how do I set it so the user selects how many lines it draws, I have a "NoOfLines" variable that I have created. I want that NoOfLines amount of these lines drawn on the open of the current bar @ TickSize ticks away.

          Comment


            #20
            Okay, I have it drawing lines automatically above and below but only 1 each, I need that to be changeable, so I can have up to 4 lines all the same distance apart etc. How can I do this?

            Also there are a LOT of lines on my chart because it's drawing them from every bar's Open, so is there a way to have it JUST on the opening bar of the session?

            Thanks!

            Comment


              #21
              Jumper, that would depend how many unique calls for the line you do, i.e. if you assign a new tag and have a different offset value from the open price > you would get another line.

              FirstBarOfSession would for example allow to have an event for the drawing to happen on the session begin only - :https://www.ninjatrader.com/support/...rofsession.htm
              BertrandNinjaTrader Customer Service

              Comment


                #22
                Yeah I found that, but how do I get it so it's the open of the first bar? Because that just returns a bool, which I obviously can't +- ticksFromPrice to.

                Comment


                  #23
                  Hello Jumper,

                  Thank you for your response.

                  You would need to store the Open[0] at when the bool is true, for example:
                  Code:
                  if(Bars.FirstBarOfSession)
                  {
                  myDblForOpen = Open[0];
                  }
                  Where myDblForOpen is a double you define to store the Open[0].

                  Comment


                    #24
                    Awesome, that's better, got it looking how I want now, my code is working! Just one thing, it seems to be running extremely slow? When I load it on a chart my whole computers starts lagging, which is weird, seems to run slower with less lines than it did before when it was drawing the lines from every bar!

                    Any ideas? Thanks for the help, great support staff :-)

                    UPDATE: The lines also don't seem to be drawing at the correct distances that user sets, I have:

                    DrawHorizontalLine("Blue" + CurrentBar, false, openPrice + ticksFromPrice, Color.Blue, DashStyle.Dot, width);
                    DrawHorizontalLine("Red" + CurrentBar, false, openPrice - ticksFromPrice, Color.Red, DashStyle.Dot, width);

                    where openPrice is the above if statement you mentioned and ticksFromPrice is well, obviously the distance I want the lines to be drawn from the first bar's opening price.
                    Last edited by Jumper; 07-28-2014, 08:04 PM.

                    Comment


                      #25
                      Nevermind, figured it out, I had separate if statements, so it must've been analysing every bar, so I put it all in the same if statement if the current bar is Bars.FirstBarOfSession and its running fine now!

                      Thanks again for the help, I'm sure I'll need it again in the future, but all good until I think up my next idea haha

                      Comment


                        #26
                        Actually just some final touches, is there a way I can have different color lines for the latest session, as in Today's trading session, just to differentiate between them and knowing which ones are the newest lines would be a little better.

                        Thanks!

                        Comment


                          #27
                          Hello Jumper,

                          Thank you for your response.

                          You could use Bars.Session.GetNextBeginEnd() to pull the begin and end time of the session. Then check if the current time is greater than the begin time and less than the end time of the session, if so use the same Draw() methods again but use different colors.

                          Information on Bars.Session.GetNextBeginEnd() can be found at the following link: http://www.ninjatrader.com/support/h...xtbeginend.htm

                          Comment


                            #28
                            Any idea why this doesn't seem to draw my dot every 600 seconds? Just drawing a dot on every bar? I want a dot every 10 minutes.
                            Attached Files

                            Comment


                              #29
                              Originally posted by Jumper View Post
                              Any idea why this doesn't seem to draw my dot every 600 seconds? Just drawing a dot on every bar? I want a dot every 10 minutes.
                              You are setting a Plot(), not drawing dots. To draw dots, per your specification, use the DrawDot() method.

                              Comment


                                #30
                                Originally posted by koganam View Post
                                You are setting a Plot(), not drawing dots. To draw dots, per your specification, use the DrawDot() method.
                                But I just copied my code from page 1 with the errors fixed that were mentioned in the next few posts there, and that code worked fine when I did it earlier in the year, and that's using a Plot(). Strange.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Perr0Grande, Today, 08:16 PM
                                0 responses
                                2 views
                                0 likes
                                Last Post Perr0Grande  
                                Started by elderan, Today, 08:03 PM
                                0 responses
                                5 views
                                0 likes
                                Last Post elderan
                                by elderan
                                 
                                Started by algospoke, Today, 06:40 PM
                                0 responses
                                10 views
                                0 likes
                                Last Post algospoke  
                                Started by maybeimnotrader, Today, 05:46 PM
                                0 responses
                                12 views
                                0 likes
                                Last Post maybeimnotrader  
                                Started by quantismo, Today, 05:13 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post quantismo  
                                Working...
                                X