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.Text value on chart and Output window value time line out of sync

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

    Draw.Text value on chart and Output window value time line out of sync

    Hello,
    I am trying to print some values from a Secondary 5MIN Series to my chart screen. The values on the chart for a specified time do not always agree with the values for the same time in the Output window. For example, on the image attached, the value for 12:40:00 is 18.39 (but that is the 12:35:00 value in the Output window) and 12:35:00 on the chart is -49.17 (but that is the 12:25 value in the Output Window).
    This is the section of the output window concerned and I have attached an image of the chart with the values on the screen.
    Code:
    23/05/2017 12:25:00 avgOs-Ob2nd=9.20 Os-Ob2ndBar0=-1.39 %Change=-115.09 ChangeIn%Bar0-Bar1 -49.17
    23/05/2017 12:30:00 avgOs-Ob2nd=7.37 Os-Ob2ndBar0=2.84 %Change=-61.43 ChangeIn%Bar0-Bar1 53.66
    23/05/2017 12:35:00 avgOs-Ob2nd=4.90 Os-Ob2ndBar0=0.16 %Change=-96.70 ChangeIn%Bar0-Bar1 18.39
    23/05/2017 12:40:00 avgOs-Ob2nd=3.06 Os-Ob2ndBar0=0.16 %Change=-94.71 ChangeIn%Bar0-Bar1 1.98
    23/05/2017 12:45:00 avgOs-Ob2nd=2.77 Os-Ob2ndBar0=6.02 %Change=117.37 ChangeIn%Bar0-Bar1 214.07
    23/05/2017 12:50:00 avgOs-Ob2nd=1.82 Os-Ob2ndBar0=-0.26 %Change=-114.16 ChangeIn%Bar0-Bar1 -231.53
    23/05/2017 12:55:00 avgOs-Ob2nd=1.05 Os-Ob2ndBar0=-7.04 %Change=-770.28 ChangeIn%Bar0-Bar1 -656.12
    23/05/2017 13:00:00 avgOs-Ob2nd=-0.94 Os-Ob2ndBar0=5.62 %Change=697.38 ChangeIn%Bar0-Bar1 747.08
    23/05/2017 13:00:00 avgOs-Ob2nd=7.51 Os-Ob2ndBar0=5.44 %Change=-27.46 ChangeIn%Bar0-Bar1 -151.84
    23/05/2017 13:00:00 avgOs-Ob2nd=2.60 Os-Ob2ndBar0=-10.05 %Change=-487.18 ChangeIn%Bar0-Bar1 -243.41
    Below is the Print and Draw.Text code which I have coded in OnBarUpdate section. The primary series is a tick chart.

    Code:
    if (BarsInProgress == 1)
    			{
    			Print(Time[0].ToString()+ " " + "avgOs-Ob2nd=" + avgOsObSecondSeries[0].ToString("0.00") +" " + "Os-Ob2ndBar0=" +
    			(My2ndDataSeriesPlots182.PrimaryOS[0] - My2ndDataSeriesPlots182.PrimaryOB[0]).ToString("0.00")
    			+ " " + "%Change=" + osObBarOAvDiffSecondSeries[0].ToString("0.00") + " " + "ChangeIn%Bar0-Bar1" + " " 
    			+ changeFromBar0ToBar1SecondSeries[0].ToString("0.00"));
    
    Draw.TextFixed(this, "texttag", 
    			"[0]"+" "+Times[1][0].ToString("HH:mm:ss") +"  "+ ChangeFromBar0ToBar1SecondSeries[0].ToString("0.00")+"\n"
    			+"[1]"+" "+Times[1][1].ToString("HH:mm:ss")+"  "+ ChangeFromBar0ToBar1SecondSeries[1].ToString("0.00")+"\n"
    			+"[2]"+" "+Times[1][2].ToString("HH:mm:ss")+"  "+ ChangeFromBar0ToBar1SecondSeries[2].ToString("0.00")+"\n"
    			+"[3]"+" "+Times[1][3].ToString("HH:mm:ss")+"  "+ ChangeFromBar0ToBar1SecondSeries[3].ToString("0.00")+"\n"
    			+"[4]"+" "+Times[1][4].ToString("HH:mm:ss")+"  "+ ChangeFromBar0ToBar1SecondSeries[4].ToString("0.00"), 
    			TextPosition.Center, textColorBrush, textFontA, Brushes.Black, Brushes.White, 10);
    			}
    Is there a way that I can write the code for the Draw.TextFixed() so that it will only pick up the value from a bar which closes at a particular time?

    Thank you.
    Attached Files

    #2
    Hello GeorgeW,

    Thank you for your post.

    The values should not be off in the code if you are comparing them to a 5 minute chart. What series is the chart? Is it a 1 minute chart?

    I look forward to your response.

    Comment


      #3
      Thanks for your response, PatrickH.

      The chart is an 854Tick chart, but the secondary series is 5Mins, which is why I call BarsInProgress == 1.

      Comment


        #4
        Hello GeorgeW,

        Thank you for your response.

        The Tick charts do not close at the same time as the Minute charts as the Tick charts are based on the number of ticks. So it is very possible to have output from a 5 Minute chart not match that from a Tick chart.

        If you would like we can test this code further if you provide the full script. You can export your indicator by going to Tools > Export > NinjaScript Add On > Add > select your indicator > OK > Export > name the file 'NTsupport' > Save. The file will be located under Documents\NinjaTrader 8\bin\Custom\ExportNinjaScript. Please attach the file to your response or send it to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H' in the subject line and a reference to this thread in the body of the email.

        I look forward to your response.

        Comment


          #5
          Hello PartickH,

          If I am calling BarsInProgress == 1, I thought the code should be picking up the close time from the 5MIN chart and not the Tick chart. Is that correct?

          I will take a look at the code again at the weekend, so won't forward it at this stage.

          Thank you.

          Comment


            #6
            Hello GeorgeW,

            Thank you for your response.

            Outputting Times[1][0] will output the secondary series, but you are comparing that to the timestamp on the chart of the Tick chart, correct?

            I look forward to your response.

            Comment


              #7
              Hello PatrickH,
              I'm not quite sure what you mean. What I am doing is trying to display the values for the movement in a plot on the 5MIN chart on my tick chart. I am trying to access the values for the last 5 bars closed on the 5MIN chart, so I want to display the time those bars closed, and the value of the movement in the plot at that time.

              Comment


                #8
                Hello GeorgeW,

                Thank you for your response.

                Please open a 5 Minute chart, does your output from the secondary series on the Tick chart match the times and values of the 5 Minute chart?

                I look forward to your response.

                Comment


                  #9
                  Hello PartickH,

                  I had a 5MIN chart opened when I tested it with the output window outputs. The plot on the 5MIN chart is in sync with the times of the output window results, but the results drawn to the Tick chart are out of sync, and not in any consistent pattern.

                  Comment


                    #10
                    Hello GeorgeW,

                    Thank you for your response.

                    Are the times that your drawing objects are drawn on the tick chart appropriate to the 5 minute chart?
                    You can check this by left clicking on the drawing tool > then right click and select Properties.

                    Likely the Drawing Tools are drawn on the timestamps of the 5 minute chart, which would be every 5 minutes. Where as the tick chart is only going to show timestamps appropriate to the times the tick bars closed - which are at no pre-determined time like a 5 minute chart.

                    Comment


                      #11
                      Hello PatrickH,

                      I believe the timestamps are based on the 5MIN chart - see image attached.
                      Attached Files

                      Comment


                        #12
                        Hello GeorgeW,

                        Thank you for your patience.

                        That would make sense as the object are using the 5 minute series. Are these timestamps showing that the objects are at the correct times on the chart?

                        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
                        4 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
                        9 views
                        0 likes
                        Last Post maybeimnotrader  
                        Started by quantismo, Today, 05:13 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post quantismo  
                        Working...
                        X