Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawTextFixed(TextPosition.TopRight) not working

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

    #16
    yes. I even tried using the wizard to do the drawings (and compiling it) (with the adjusted y) and nothing comes out.

    Comment


      #17
      Are there any errors in the log files (right-most tab of Control Center)?
      AustinNinjaTrader Customer Service

      Comment


        #18
        nope. is there any sample code you can show/send me for me to test?

        Comment


          #19
          nightriderx, the code is exactly as I posted it above. Please see this screenshot and the attached script for a test.

          EDIT: Sorry, forgot you were using diamonds instead of dots. The code should be exactly the same, but with Diamond instead of Dot in the code.
          Attached Files
          AustinNinjaTrader Customer Service

          Comment


            #20
            Hey, I believe the folder you sent is empty...
            However, I noticed its called "indicator" - can you please tell me - is it possible to draw on the chart from a strategy - not from an indicator?

            Comment


              #21
              nightriderx, the indicator is contained inside the indicator folder. You can import the .zip by going to File -> Utilities -> Import NinjaScript.

              It is also possible to draw on the chart from a strategy, as well as from indicators.
              AustinNinjaTrader Customer Service

              Comment


                #22
                Thanks. Windows said the folder was empty, strange.
                Anyhow, I was able to use the indicator successfully, however when trying to add the Add(new Plot... in initialize section, i get the following error:

                Argument '1': cannot convert from 'NinjaTrader.Gui.Chart.Plot' to 'NinjaTrader.Indicator.IndicatorBase' CS1503 - click for info 64 8

                its the same error I got before when trying to draw

                Thx!

                Comment


                  #23
                  Hi there, could you please post the complete code you're using so I can see if anything else is out of place?
                  AustinNinjaTrader Customer Service

                  Comment


                    #24
                    #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

                    namespace NinjaTrader.Strategy
                    {


                    public class Diamonds : Strategy
                    {
                    #region Variables

                    private int myInput0 = 1; // Default setting for MyInput0


                    private string stock1 = "QQQQ";
                    private string stock2 = "DJI";


                    #endregion


                    protected override void Initialize()
                    {


                    Add(PeriodType.Tick, 1);
                    Add(stock1, PeriodType.Second, 2);
                    Add(stock2, PeriodType.Second, 2);


                    CalculateOnBarClose = false;

                    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));


                    }




                    protected override void OnBarUpdate()
                    {
                    if (Closes[1][0] < Closes[1][1])
                    {

                    EnterLong();
                    MaxTime = 1;
                    DrawDiamond("my diamond" + CurrentBar, false, 0, Low[0] * TickSize, Color.Red);

                    }


                    if (BarsInProgress == 0 && Positions[1].MarketPosition == MarketPosition.Long)
                    {
                    if (MaxTime < 2)
                    {
                    ExitLong();
                    DrawDiamond("my diamond" + CurrentBar, false, 0, Low[0] * TickSize, Color.Red);

                    }
                    }
                    }
                    }
                    }
                    Last edited by nightriderx; 07-21-2010, 04:05 PM.

                    Comment


                      #25
                      nightriderx, if there are no errors in the logs, your diamonds are being drawn, but at the wrong price. Right now you have the y coordinate of the diamonds set to Low[0] * TickSize, which would most definitely be off of the chart for most instruments. On ES, for example, lets take a low of 1050 and multiply it by the tick size of 0.25. 1050 * 0.25 = 262.5, which is where your diamond would be drawn if this strategy is running on ES. YM would be one instrument where this should draw correctly because the tick size is 1.

                      Please change the y coordinates to something like Low[0] - 2 * TickSize. In addition, it could be that the conditions for your dot to be drawn aren't being met. It looks like you are using two second QQQQ bars for the entry signal. You may want to try extending that time a bit just to get a feel for how drawing objects work.
                      AustinNinjaTrader Customer Service

                      Comment


                        #26
                        thank you for your help. However, I have tried every thinkable instance of y, including actual price values (which are visible), changing from tick to seconds/minutes and even taking it out of the if statements to print at every bar and tried every other bar...however have seen no results. Can you please be so kind to point me to where I can find a sample Strategy (not indicator) which draws something - to use as a reference?

                        thx

                        Comment


                          #27
                          Hi again, just to double check, are you re-compiling your scripts after making changes and then reloading the script on the chart? Or if you are running your strategy in the strategy tab, reloading it from there?

                          I have created a strategy that draws dots, just for you. Please take a look at the attachments.
                          Attached Files
                          AustinNinjaTrader Customer Service

                          Comment


                            #28
                            ok, I apologize, I did not realize that you have to manually load the strategies in the chart for the drawings to appear (assumed it does that automatically as it does for buy/sell signs)
                            once loaded - all works great! thank you very much for your help!!

                            just one last thing, can you please point me to where I can learn exactly how/why you must multiply Y by TickSize?

                            Comment


                              #29
                              The only reason I include TickSize in the y calculations is to offset the drawing from the price bars by a little bit. You could use Low[0] or High[0] without any TickSize adjustment, but the draw objects would be right against the bars, and that could make the chart look a bit cluttered.
                              AustinNinjaTrader Customer Service

                              Comment


                                #30
                                gotcha. Austin, thank you for all of your help once again!

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                607 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                353 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                560 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                561 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X