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 Rectangle Open[2][1] Close[2][1]

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

    Draw Rectangle Open[2][1] Close[2][1]

    Hey guys, this is the thing, right now im just Ploting moving Averages at the Closes[1] & Opens[1] but its kind confusing visually, i would like to have a rectangle drawn for each closed bar of a bigger TimeFrame, it cant be that hard, how can i do it with DrawRectangle?

    thanks in advance!

    #2
    Hello kabott,

    Thank you for your post.

    The following code will draw a rectangel from the open of the current bar to the close starting 1 bar ago.
    Code:
    			if(BarsInProgress == 1)
    			{
    				DrawRectangle("tag", 1, Opens[1][0], 0, Closes[1][0], Color.Blue);
    			}

    Comment


      #3
      Hi Patrick, thanks for your previous help, i've played with the snippet a bit , see if i can make it plot properly but failed :/ how can i make the rectangles extend all the way to the beginning of the next bar ?

      One more non-related question , why do i get pop-ups saying "Unable to write cache data" when i try to create / reload a chart? thank you in advance




      Click image for larger version

Name:	$USDCAD ( RJay's RenkoHybrid  4 Tick)  10_09_2014.jpg
Views:	1
Size:	71.8 KB
ID:	871172


      if(BarsInProgress == 1)
      {

      DrawRectangle( "Tag"+CurrentBars[1] , true, 0, Opens[1][0] , 3 , Closes[1][0] ,Color.Blue, Color.Blue, 2);

      }
      Last edited by kabott; 09-10-2014, 09:35 PM.

      Comment


        #4
        Hello kabott,

        Thank you for your response.

        Please try the following:
        Code:
        DrawRectangle( "Tag"+CurrentBars[1] , true, 3, Opens[1][0] , -1 , Closes[1][0] ,Color.Blue, Color.Blue, 2);
        For the error message I would need to review your log and trace files. Please send these by going to Help > Mail To Platform Support > ensure the log and trace files option is enabled. Please put "ATTN: Patrick - http://www.ninjatrader.com/support/forum/showthread.php?t=68698" in the subject line.

        Comment


          #5
          Hi Patrick, i already sent you the trace files to the address you requested,
          Ive tried the snippet you gaved me but the rectangles dont extend all the way to the begging of the next bar open

          Click image for larger version

Name:	$EURAUD ( RJay's RenkoHybrid  4 Tick)  09_09_2014.jpg
Views:	1
Size:	73.9 KB
ID:	872302

          i think there is something missing, like, shouldn't somehow tell the drawRectangle how many bars extend to the right ? i mean something of a bar counter, counting the bars[0] generated since the last bar[1] close and then when this one closes use that count to generate the rectangle?

          Comment


            #6
            Hello kabott,

            Thank you for your response.

            0 would be the current bar as far as bars ago. So you would want to set the end bars ago to 0 and then set your CalculatOnBarClose to False. That should plot the rectangle to the current bar's open.

            If not, please provide a screenshot of the rectangle manually drawn on the chart as you would like to see it and provide me the code you are using.

            Comment


              #7
              Hi Patrick, sorry to be such a pain, i though it was easyer, this is how it should plot the rectangles, basically i wanna see whats going on inside the range of a higher time-frame Renko

              current ploting
              Click image for larger version

Name:	a.jpg
Views:	1
Size:	89.2 KB
ID:	872303

              How it should be
              Click image for larger version

Name:	b.jpg
Views:	1
Size:	90.1 KB
ID:	872304

              Thanks againg

              edit: sorry, i made a mistake, the rectangle at the top should be blue

              Comment


                #8
                Patrick, here is a better example of what im looking to create
                so, with this one should be able to "see" inside a higher time frame range, later i can add some alerts using the original moving averages etc, but this way looks so much comprehensible to me, one look and i can understand whats going on at a higher time frame

                Click image for larger version

Name:	ejample 2.jpg
Views:	1
Size:	178.2 KB
ID:	872305

                thanks again for your help Patrick

                Comment


                  #9
                  Hello kabott,

                  Thank you for your response.

                  So I may get a better idea of how this works can you provide the code you are trying to use that is not producing the results you want?

                  Comment


                    #10
                    Sure thing!
                    Here it is and this is how is looking so far, i managed to somewhat accomplish what i wanted without the DrawRectangle , its still there just inactive, it would be great to have it working
                    Last edited by kabott; 09-13-2014, 04:58 PM.

                    Comment


                      #11
                      Kabott,

                      Thank you for your file.

                      The reason you are seeing these results is because you can only draw to the primary time frame/data series.

                      This also includes the bars for the primary bar and not the ones from the secondary calculation.

                      If you want to get the bar count from the day to translate to the primary, you will need to calculate when the bars will begin and end in the secondary data series and then translate that to the primary for the correct number of bars.
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Hey Cal, thanks for your response, and how can i do what your suggesting?, any examples i can look at? where do i begin? ill appreciate any help i can get

                        Comment


                          #13
                          Kabott,

                          I don't have any examples available.

                          You may want to look into using GetBar() and Time data value.
                          http://www.ninjatrader.com/support/helpGuides/nt7/index.html?time.htm

                          http://www.ninjatrader.com/support/h...tml?getbar.htm
                          Cal H.NinjaTrader Customer Service

                          Comment


                            #14
                            Candlestick pattern indicator

                            Originally posted by NinjaTrader_Cal View Post
                            Kabott,

                            Thank you for your file.

                            The reason you are seeing these results is because you can only draw to the primary time frame/data series.

                            This also includes the bars for the primary bar and not the ones from the secondary calculation.

                            If you want to get the bar count from the day to translate to the primary, you will need to calculate when the bars will begin and end in the secondary data series and then translate that to the primary for the correct number of bars.
                            Cal,

                            Can you tell me how to set a voice alert on say for example on a bullish engulfing pattern once it had been identified on the chart. The voice alert would let me know it showed up on the chart.

                            Comment


                              #15
                              Hello,

                              Thank you for the question.

                              For adding alerts or other sounds to NinjaScript you have a few options on what you can use.

                              One option is the PlaySound() method, this simply plays sounds when it is called. If this is used in a loop it would play every time its called so take note of that. Here is the documentation on it: http://www.ninjatrader.com/support/h.../playsound.htm

                              Additionally you have Alert() method which is a more advanced alert than just a sound, this allows you to play a sound, alert the alerts panel (File - new - alerts) and set a re arm time so it plays again only after X amount of seconds. Here is the documentation: http://www.ninjatrader.com/support/h.../nt7/alert.htm

                              Once you have made the logic that determines when this will happen you would just need one of the above statements.

                              For voice alerts, you would need to locate a file with the voice you want, NinjaTrader only supports .wav files so it would need to be an audio clip of a voice to be used.

                              Please let me know if I may be of additional assistance.
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by techgetgame, Yesterday, 11:42 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post techgetgame  
                              Started by sephichapdson, Yesterday, 11:36 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post sephichapdson  
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,615 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Yesterday, 05:56 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              20 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Working...
                              X