Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawDot...

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

    #16
    Hello,

    OK. I did that. And it did not solve the problem. The dot is still on the wrong bar. All it does now is give me two dots on the bar where the stragety was started. See the attached screen shot. The dot should be on the current bar.

    I seem to be failing to communicate the problem. The DrawDot command field of barsAgo does not draw a dot on the current bar when 0 is used. That is the problem.

    Ciao,

    Mark
    Attached Files

    Comment


      #17
      OnMarketData is not back-testable.

      Therefore, this function will only be called in real-time when your criteria is met.

      I don't know why you are seeing this on the bar the strategy was started, but anything in the future after that will only show as the OnMarketData is called in real time.
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #18
        Mark,

        Post up your whole code. As mrlogik pointed out, OnMarketData is for real-time.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          Hello,

          >Post up your whole code. As mrlogik pointed out, OnMarketData is for real-time.

          I can not post the logic. I only removed the logic replaced by X in the code I posted, otherwise that is it. There is no more.

          I know it is real-time. That is why I selected it.

          We are getting off point, of the dot not being on the currentBar as defined by barsAgo in drawDot.

          You did not answer my question, have you looked at the screen shots? Do you see the error?

          Ciao,

          Mark

          Comment


            #20
            Mark,

            As we have mentioned already. It will plot wherever the dot goes. Unfortunately we cannot assist you further unless you post up the full indicator so we can try it on our end. If you want to change the logic go ahead, but until we have the full indicator as well as the exact steps in which you use the indicator we cannot proceed.
            Josh P.NinjaTrader Customer Service

            Comment


              #21
              Hey,

              It is a strategy not an indicator. "It will plot wherever the dot goes". I do not understand.

              This took 3 minutes to write and shows the problem.

              #region Using declarations
              using System;
              using System.ComponentModel;
              using System.Diagnostics;
              using System.Drawing;
              using System.Drawing.Drawing2D;
              using System.Xml.Serialization;
              using NinjaTrader.Cbi;
              using NinjaTrader.Data;
              using NinjaTrader.Indicator;
              using NinjaTrader.Gui.Chart;
              using NinjaTrader.Strategy;
              #endregion
              // This namespace holds all strategies and is required. Do not change it.
              namespace NinjaTrader.Strategy
              {
              /// <summary>
              /// To test if a dot can be draw on the current bar inside the OnMarketData.
              /// </summary>
              [Description("To test if a dot can be draw on the current bar inside the OnMarketData.")]
              public class TestDot : Strategy
              {
              #region Variables
              // Wizard generated variables
              private int myInput0 = 1; // Default setting for MyInput0
              int dotCounter = 0;
              // User defined variables (add any user defined variables below)
              #endregion
              /// <summary>
              /// This method is used to configure the strategy and is called once before any strategy method is called.
              /// </summary>
              protected override void Initialize()
              {
              CalculateOnBarClose = true;
              }
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnMarketData(MarketDataEventArgs e)
              {
              DrawDot(CurrentBar.ToString() + dotCounter.ToString(), true, 0, Median[0],Color.Blue);
              dotCounter++;
              }
              #region Properties
              [Description("")]
              [Category("Parameters")]
              public int MyInput0
              {
              get { return myInput0; }
              set { myInput0 = Math.Max(1, value); }
              }
              #endregion
              }
              }

              All of the dots appear on the bar that the stragety started.

              Make a 50 tick chart of ES-030 and you will see a vertical row of blue dots appear on the bar the stragety started.

              Mark

              Comment


                #22
                You have removed the OnBarUpdate section.
                Try adding it back in where it was originally.

                protected override void OnBarUpdate()
                {}

                Comment


                  #23
                  Thank you MJT. As you add back the OnBarUpdate() it will resolve your issues.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    Hello,

                    OK much better.

                    It is now on the correct bar but it only is displayed when the bar is closed. I want it to show when I call DrawDot.

                    The next question is how to get the current price. The price is shown by the indicator on the far right (black pointer). I want the dot to appear on the same horizontal plane.

                    Thanks to all,

                    Mark

                    Comment


                      #25
                      Mark,
                      You have "CalculateOnBarClose = true;" in the Initialize section. Change it to false, and it will update every tick. That is still not what you really want which is to update with every change in OnMarketData, but I think that goes well beyond the officially supported features, so don't expect Ninja folks to explain how it's done. I believe you could refresh the chart from within OnMarketData, but have never done that myself.
                      The way you have it coded now, it will draw a new dot each time.

                      To get the current price, within DrawDot() change Median[0] to Close[0].

                      Comment


                        #26
                        Hi,

                        Thanks. Yeah in my real strategy I had set that to false. I have not gotten back to it yet. I was still working on the demo code.

                        OK. So I guess the Close[0] always has the current price.

                        Yeah, the real logic is not present. It does not fire that often but when it does I want to get the data on the chart as fast as possible. It is edge triggerd so only one dot will appear on the bar.

                        Ciao,

                        Mark

                        Comment


                          #27
                          Close[0] is the last traded price when in real-time with CalculateOnBarClose = false.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #28
                            Hi,

                            Thanks.

                            Is there a faster method to get a dot, or really any symbol, on the screen than drawXXX with the symbol at the current bar and current price location.

                            Ciao,

                            Mark

                            Comment


                              #29
                              Mark,

                              Unfortunately not.
                              RayNinjaTrader Customer Service

                              Comment


                                #30
                                Hello,

                                OK Thanks.

                                Ciao,

                                Mark

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                656 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                371 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                579 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X