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

OnRenderToDrawText.zip error TextFormat

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

    OnRenderToDrawText.zip error TextFormat

    Trying to incorporate this into my indicator from an old SimpleFont to a Render method so I can place text where I want it.

    Have all errors removed finally but still getting one that I just cannot figure out

    "The type or namespace name "TextFormat" could not be found.", line 93, col 13 37

    Any help would be appreciated.


    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class TimeFrameContinuity : Indicator
        {
            private Text mytexttool;
            private Brush axisColor;
            private    Gui.Tools.SimpleFont chartFont;
            private Brush TimeFrameColor;
            private Text TimeframeLabel;
    //        private Brush Color5M;
    //        private Brush Color30M;
    //        private Brush ColorHour;
    //        private Brush ColorDay;
    //        private Brush ColorWeek;
    //        private Brush ColorMonth;
    
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Shows 5/15/30/H/D/W/M Status";
                    Name                                        = "TimeFrameContinuity";
                    Calculate                                    = Calculate.OnPriceChange;
                    IsOverlay                                    = true;
                    DisplayInDataBox                            = false;
                    DrawOnPricePanel                            = false;
                    DrawHorizontalGridLines                        = false;
                    DrawVerticalGridLines                        = false;
                    PaintPriceMarkers                            = false;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Overlay;
                    IsSuspendedWhileInactive    = true;
                    BarsRequiredToPlot = 0;
                    //    IsSuspendedWhileInactive                    = true;
    
                }
                else if (State == State.DataLoaded)    {
                    if (ChartControl != null)
                    {
                        chartFont = new SimpleFont("Arial", 12) { Bold = true };
                    }
    
                }
                    else if (State == State.Configure)
                {
    
                }
            }
    
            protected override void OnBarUpdate()
            {
    
                if(CurrentBar<1) return; 
    
    
    
            }
            protected override void OnRender(ChartControl chartControl, ChartScale chartScale){
                if(BarsPeriod.BarsPeriodType != BarsPeriodType.Minute) return;        
    
                //Call base.OnRender() to ensure all base behavior is performed
                base.OnRender(chartControl, chartScale);
    
                // Instatiate a factory, which is required for the next step
                SharpDX.DirectWrite.Factory factory = new SharpDX.DirectWrite.Factory();
                //SharpDX.DirectWrite.TextFormat textFormat = new TextFormat(factory, "Arial", 17);
    
                // Instantiate a TextFormat, using our factory
                TextFormat format = new TextFormat(factory, "Arial", 17);
    
                // Instantiate a Direct2D1 brush, using the System.Media.Brush Brushes collection
                SharpDX.Direct2D1.Brush textBrush = Brushes.Green.ToDxBrush(RenderTarget);
    
                int startPointY=(int)(ChartPanel.H*.9);
                int startPointX=15;//(int)(ChartPanel.W*.1);
    
            // Instantiate a rectangle to hold our text
    //            SharpDX.Rectangle textRectangle7 = new SharpDX.Rectangle(startPointX*7, startPointY, 50, 30);
    //            SharpDX.Rectangle textRectangle6 = new SharpDX.Rectangle(startPointX*6, startPointY, 50, 30);
    //            SharpDX.Rectangle textRectangle5 = new SharpDX.Rectangle(startPointX*5, startPointY, 50, 30);
    //            SharpDX.Rectangle textRectangle4 = new SharpDX.Rectangle(startPointX*4, startPointY, 50, 30);
    //            SharpDX.Rectangle textRectangle3 = new SharpDX.Rectangle(startPointX*3, startPointY, 50, 30);
    //            SharpDX.Rectangle textRectangle2 = new SharpDX.Rectangle(startPointX*2, startPointY, 50, 30);
    //            SharpDX.Rectangle textRectangle1 = new SharpDX.Rectangle(startPointX, startPointY, 50, 30);
    
    
    
    //            RenderTarget.DrawText("M", format, textRectangle1, textBrush);
    //            RenderTarget.DrawText("W", format, textRectangle2, textBrush);
    //            RenderTarget.DrawText("D", format, textRectangle3, textBrush);
    //            RenderTarget.DrawText("H", format, textRectangle4, textBrush);
    //            RenderTarget.DrawText("30", format, textRectangle5, textBrush);
    //            RenderTarget.DrawText("15", format, textRectangle6, textBrush);
    //            RenderTarget.DrawText("5", format, textRectangle7, textBrush);
    
    
    
            }    
            #region Properties
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> Signal5M
            {
                get { return Values[0]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> Signal30M
            {
                get { return Values[1]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> Signal60M
            {
                get { return Values[2]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> SignalDay
            {
                get { return Values[3]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> SignalWeek
            {
                get { return Values[4]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> SignalMonth
            {
                get { return Values[5]; }
            }
            #endregion
    
        }
    
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private TimeFrameContinuity[] cacheTimeFrameContinuity;
            public TimeFrameContinuity TimeFrameContinuity()
            {
                return TimeFrameContinuity(Input);
            }
    
            public TimeFrameContinuity TimeFrameContinuity(ISeries<double> input)
            {
                if (cacheTimeFrameContinuity != null)
                    for (int idx = 0; idx < cacheTimeFrameContinuity.Length; idx++)
                        if (cacheTimeFrameContinuity[idx] != null &&  cacheTimeFrameContinuity[idx].EqualsInput(input))
                            return cacheTimeFrameContinuity[idx];
                return CacheIndicator<TimeFrameContinuity>(new TimeFrameContinuity(), input, ref cacheTimeFrameContinuity);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.TimeFrameContinuity TimeFrameContinuity()
            {
                return indicator.TimeFrameContinuity(Input);
            }
    
            public Indicators.TimeFrameContinuity TimeFrameContinuity(ISeries<double> input )
            {
                return indicator.TimeFrameContinuity(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.TimeFrameContinuity TimeFrameContinuity()
            {
                return indicator.TimeFrameContinuity(Input);
            }
    
            public Indicators.TimeFrameContinuity TimeFrameContinuity(ISeries<double> input )
            {
                return indicator.TimeFrameContinuity(input);
            }
        }
    }
    
    #endregion

    #2
    Hi, thanks for your question.

    It looks like TextFormat is a part of System.Management.dll did you add a reference to this and add "using System.Management" to the include statements?

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Rogers101, 05-05-2024, 11:30 AM
    16 responses
    49 views
    0 likes
    Last Post Rogers101  
    Started by ninza33, Today, 12:31 PM
    2 responses
    9 views
    0 likes
    Last Post ninza33
    by ninza33
     
    Started by Bobin, 03-12-2024, 08:51 AM
    15 responses
    481 views
    0 likes
    Last Post fiddich
    by fiddich
     
    Started by Skifree, Today, 11:21 AM
    4 responses
    14 views
    0 likes
    Last Post Skifree
    by Skifree
     
    Started by Bogdan097, Today, 03:25 PM
    0 responses
    8 views
    0 likes
    Last Post Bogdan097  
    Working...
    X