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

visal problems with plotting

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

    visal problems with plotting

    Hello Ninja Trader support,

    I encountered a visual problem on plotting lines in the chart.

    That's how the chart should look like, and is shown after the strategy/indicator is applied to the chart:
    Click image for larger version

Name:	plotting1.png
Views:	159
Size:	56.1 KB
ID:	1065741


    After reloading ninjatrader script or after the chart updates I get this: The plotting is displaced by some points
    Click image for larger version

Name:	plotting2.png
Views:	142
Size:	74.6 KB
ID:	1065742

    Any advice on this?

    In code I use
    in set default state:

    Code:
        AddPlot(new Stroke(Brushes.Gray, DashStyleHelper.DashDot, 2f), PlotStyle.Line, "Plot1");
                    AddPlot(new Stroke(Brushes.Gray, DashStyleHelper.DashDot, 2f), PlotStyle.Line, "Plot2");
    In on Data loaded:
    Code:
      ausenstaebe = new Series<bool>(this,MaximumBarsLookBack.Infinite);
                    oberkante = new Series<double>(this,MaximumBarsLookBack.Infinite);
                    unterkante = new Series<double>(this, MaximumBarsLookBack.Infinite);
    Then in OnBarUpdate I'm setting the values:
    Code:
      Values[0][0] = currentHigh;
                    Values[1][0] = currentLow;
                    oberkante[0] = currentHigh;
                    unterkante[0] = currentLow;
                    ausenstaebe[0] = true;
    The values are all the time correct, so I'm pretty sure it's just a visual problem but I was not able to fix this so far.

    Best regards,
    Johnny

    #2
    Hello Johnny90,

    Thank you for the question.

    How are you currently calculating the values you are plotting?

    Also how are you confirming the values are correct? Are you printing or just using the charts databox?

    If the plot is being shifted, that would generally entail the supplied value had changed somehow, have you printed the plot value in both use cases to directly compare the values in both tests for each bar? That may be helpful in this case.

    You also noted this is after reloading, this could be a result of differences in processing between historical and realtime. If the first image was built from realtime data, that may provide a hint at what to look at. If that's the case, changing to using TickReplay may help depending on how the values are calculated.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      thanks for your reply. I compared the values in the databox. As you can see, the correct value is 12157 but the line is painted at 12140. I'm using the indicator for trailing stop mechanic in live trading so I'm absolutly sure the calculation is correct.
      Click image for larger version

Name:	plotting3.png
Views:	157
Size:	85.7 KB
ID:	1065875

      Calculation is

      Code:
       int last = CurrentBar - 1;
                  int current = CurrentBar;
      
                  double lastHigh = oberkante.GetValueAt(last);
                  double lastLow = unterkante.GetValueAt(last);
                  double lastClose = Close.GetValueAt(last);
      
                  double currentClose = Close.GetValueAt(current);
                  double currentLow = Low.GetValueAt(current);
                  double currentHigh = High.GetValueAt(current);
      
                  if ((currentClose >= Math.Round(lastHigh + KulanzPunkte, 2)) ||
                          (currentClose <= Math.Round(lastLow - KulanzPunkte , 2)) || 
                          (NeuerHandeltagAlsAusenstab && Bars.IsFirstBarOfSession))
                  {
                      //Außenstab
                      Values[0][0] = currentHigh;
                      Values[1][0] = currentLow;
                      oberkante[0] = currentHigh;
                      unterkante[0] = currentLow;
                      ausenstaebe[0] = true;
                  }
      In the series i'm using the update command:

      Code:
        private Series<bool> ausenstaebe;
              public Series<bool> Austenstab
              {
                  get
                  {
                      Update();
                      return ausenstaebe;
                  }
              }
      Any advice?

      Best regards,
      Johnny

      Comment


        #4
        Hello Johnny90,

        Thank you for the reply.

        From what has been provided I am not able to see what may be the problem. Could you export a sample script which demonstrates this happening for you? I would like to try this on my end to see if I also get the same result.

        Alternatively, have you tried setting the values to static values to see if it shifts in the same use case? For example using a number or a Close[0], something which is not being calculated/rounded.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          sure, please see the attached indicator.
          Apply it to any index future chart. To get the shifting reload ninjatrader script or scroll the chart a bit, sometimes it's right from the beginning "shifted" sometimes it takes some time/bar updates.

          Best regards,
          Johnny
          Attached Files

          Comment


            #6
            Hello Johnny90,

            Thanks for your reply.

            This is Paul responding for Jesse who is out of the office today.

            The indicator coding has the Scale Justification set to "Overlay" which I suspect is the issue here. Please set it to the "Right" to match up with the price data and retest.

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hello Paul,

              thanks, the problem seems solved now.

              Best regards,
              Johnny

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              3 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              6 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Working...
              X