• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cannot plot strings in custom market analyser column

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

    cannot plot strings in custom market analyser column

    I just created a sample to demonstrate a problem. I have a custom value in my indicator that I want to print in my custommarketanalyser column. I get the following error whenever I use it.
    A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
    Exception at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLockCore(TimeoutTracker timeout)
    at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLock(TimeoutTracker timeout)
    at NinjaTrader.Data.BarsSeries.Dispose()
    at NinjaTrader.Data.Bars.Dispose(Boolean disposing)
    at NinjaTrader.Data.Bars.Dispose()
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetState(S tate state)
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetUp()
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetState(S tate state)
    at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Se tState(State state)
    at NinjaTrader.NinjaScript.IndicatorBase.CacheIndicat or[T](T indicator, ISeries`1 input, T[]& cache)
    at NinjaTrader.NinjaScript.Indicators.Indicator.STSVe r2(ISeries`1 input) in c:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\Indicators\STSVer2.cs:line 426
    at NinjaTrader.NinjaScript.MarketAnalyzerColumns.Mark etAnalyzerColumn.STSVer2() in c:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\Indicators\STSVer2.cs:line 437
    at NinjaTrader.NinjaScript.MarketAnalyzerColumns.MyCu stomMarketAnalyzerColumn.OnBarUpdate() in c:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\MarketAnalyzerColumns\MyCustomMarketA nalyzerColumn.cs:line 47

    here is the code for both the indicator and marketanalyser column
    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.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    
    #endregion
    
    //This namespace holds MarketAnalyzerColumns in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    	public class MyCustomMarketAnalyzerColumn : MarketAnalyzerColumn
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom Market Analyzer Column here.";
    				Name								= "MyCustomMarketAnalyzerColumn";
    				Calculate							= Calculate.OnEachTick;
    			}
    			else if (State == State.Configure)
    			{
    			}
    		}
    		protected override void OnBarUpdate()
            {
    			try{
    				if(State==State.Realtime){
    				
    			// Print(STSVer2().BounceState[0] +   STSVer2().MarketDirection[0] );
    				Print(ATR(14)[1]);
    				if(STSVer2().plotfirst100barhigh.IsValidDataPoint(0)){
    			CurrentText =MyCustomIndicator(0).CustomValues[0].ToString();
    				}
    				}
    				 }
                catch (Exception eX)
                {
                    PrintTo = PrintTo.OutputTab1;
                    Print("Exception " + eX.StackTrace);
                }
    		}
    		
    		
    	}
    }
    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.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 MyCustomIndicator : Indicator
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom Indicator here.";
    				Name								= "MyCustomIndicator";
    				Calculate							= Calculate.OnBarClose;
    				IsOverlay							= false;
    				DisplayInDataBox					= true;
    				DrawOnPricePanel					= false;
    				DrawHorizontalGridLines				= true;
    				DrawVerticalGridLines				= true;
    				PaintPriceMarkers					= true;
    				ScaleJustification					= NinjaTrader.Gui.Chart.ScaleJustification.Right;
    				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
    				//See Help Guide for additional information.
    				IsSuspendedWhileInactive			= true;
    				 AddPlot(Brushes.Orange, "test");
    			}
    			else if (State == State.Configure)
    			{
    				
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			if(CurrentBar<20)
    				return;
    			//Add your custom indicator logic here.
    			Value[0]=1;
    			    
    		}
    		#region Properties
    		[Range(1, int.MaxValue)]
    		[NinjaScriptProperty]
    		[Display(Name="Period", Order=1, GroupName="Parameters")]
    		public int Period
    		{ get; set; }
    
    		[Browsable(false)]
    		[XmlIgnore]
    		public Series<double> CustomValues
    		{
    			get { return Values[0]; }
    		}
    		#endregion
    	}
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
    	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    	{
    		private MyCustomIndicator[] cacheMyCustomIndicator;
    		public MyCustomIndicator MyCustomIndicator(int period)
    		{
    			return MyCustomIndicator(Input, period);
    		}
    
    		public MyCustomIndicator MyCustomIndicator(ISeries<double> input, int period)
    		{
    			if (cacheMyCustomIndicator != null)
    				for (int idx = 0; idx < cacheMyCustomIndicator.Length; idx++)
    					if (cacheMyCustomIndicator[idx] != null && cacheMyCustomIndicator[idx].Period == period && cacheMyCustomIndicator[idx].EqualsInput(input))
    						return cacheMyCustomIndicator[idx];
    			return CacheIndicator<MyCustomIndicator>(new MyCustomIndicator(){ Period = period }, input, ref cacheMyCustomIndicator);
    		}
    	}
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    	{
    		public Indicators.MyCustomIndicator MyCustomIndicator(int period)
    		{
    			return indicator.MyCustomIndicator(Input, period);
    		}
    
    		public Indicators.MyCustomIndicator MyCustomIndicator(ISeries<double> input , int period)
    		{
    			return indicator.MyCustomIndicator(input, period);
    		}
    	}
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
    	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    	{
    		public Indicators.MyCustomIndicator MyCustomIndicator(int period)
    		{
    			return indicator.MyCustomIndicator(Input, period);
    		}
    
    		public Indicators.MyCustomIndicator MyCustomIndicator(ISeries<double> input , int period)
    		{
    			return indicator.MyCustomIndicator(input, period);
    		}
    	}
    }
    
    #endregion

    #2
    Originally posted by junkone View Post
    I just created a sample to demonstrate a problem. I have a custom value in my indicator that I want to print in my custommarketanalyser column. I get the following error whenever I use it.
    A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
    Exception at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLockCore(TimeoutTracker timeout)
    at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLock(TimeoutTracker timeout)
    at NinjaTrader.Data.BarsSeries.Dispose()
    at NinjaTrader.Data.Bars.Dispose(Boolean disposing)
    at NinjaTrader.Data.Bars.Dispose()
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetState(S tate state)
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetUp()
    at NinjaTrader.NinjaScript.NinjaScriptBase.SetState(S tate state)
    at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Se tState(State state)
    at NinjaTrader.NinjaScript.IndicatorBase.CacheIndicat or[T](T indicator, ISeries`1 input, T[]& cache)
    at NinjaTrader.NinjaScript.Indicators.Indicator.STSVe r2(ISeries`1 input) in c:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\Indicators\STSVer2.cs:line 426
    at NinjaTrader.NinjaScript.MarketAnalyzerColumns.Mark etAnalyzerColumn.STSVer2() in c:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\Indicators\STSVer2.cs:line 437
    at NinjaTrader.NinjaScript.MarketAnalyzerColumns.MyCu stomMarketAnalyzerColumn.OnBarUpdate() in c:\Users\Suresh\Documents\NinjaTrader 8\bin\Custom\MarketAnalyzerColumns\MyCustomMarketA nalyzerColumn.cs:line 47

    here is the code for both the indicator and marketanalyser column
    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.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    
    #endregion
    
    //This namespace holds MarketAnalyzerColumns in this folder and is required. Do not change it. 
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    	public class MyCustomMarketAnalyzerColumn : MarketAnalyzerColumn
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom Market Analyzer Column here.";
    				Name								= "MyCustomMarketAnalyzerColumn";
    				Calculate							= Calculate.OnEachTick;
    			}
    			else if (State == State.Configure)
    			{
    			}
    		}
    		protected override void OnBarUpdate()
            {
    			try{
    				if(State==State.Realtime){
    				
    			// Print(STSVer2().BounceState[0] +   STSVer2().MarketDirection[0] );
    				Print(ATR(14)[1]);
    				if(STSVer2().plotfirst100barhigh.IsValidDataPoint(0)){
    			CurrentText =MyCustomIndicator(0).CustomValues[0].ToString();
    				}
    				}
    				 }
                catch (Exception eX)
                {
                    PrintTo = PrintTo.OutputTab1;
                    Print("Exception " + eX.StackTrace);
                }
    		}
    		
    		
    	}
    }
    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.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 MyCustomIndicator : Indicator
    	{
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description							= @"Enter the description for your new custom Indicator here.";
    				Name								= "MyCustomIndicator";
    				Calculate							= Calculate.OnBarClose;
    				IsOverlay							= false;
    				DisplayInDataBox					= true;
    				DrawOnPricePanel					= false;
    				DrawHorizontalGridLines				= true;
    				DrawVerticalGridLines				= true;
    				PaintPriceMarkers					= true;
    				ScaleJustification					= NinjaTrader.Gui.Chart.ScaleJustification.Right;
    				//Disable this property if your indicator requires custom values that cumulate with each new market data event. 
    				//See Help Guide for additional information.
    				IsSuspendedWhileInactive			= true;
    				 AddPlot(Brushes.Orange, "test");
    			}
    			else if (State == State.Configure)
    			{
    				
    			}
    		}
    
    		protected override void OnBarUpdate()
    		{
    			if(CurrentBar<20)
    				return;
    			//Add your custom indicator logic here.
    			Value[0]=1;
    			    
    		}
    		#region Properties
    		[Range(1, int.MaxValue)]
    		[NinjaScriptProperty]
    		[Display(Name="Period", Order=1, GroupName="Parameters")]
    		public int Period
    		{ get; set; }
    
    		[Browsable(false)]
    		[XmlIgnore]
    		public Series<double> CustomValues
    		{
    			get { return Values[0]; }
    		}
    		#endregion
    	}
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
    	public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    	{
    		private MyCustomIndicator[] cacheMyCustomIndicator;
    		public MyCustomIndicator MyCustomIndicator(int period)
    		{
    			return MyCustomIndicator(Input, period);
    		}
    
    		public MyCustomIndicator MyCustomIndicator(ISeries<double> input, int period)
    		{
    			if (cacheMyCustomIndicator != null)
    				for (int idx = 0; idx < cacheMyCustomIndicator.Length; idx++)
    					if (cacheMyCustomIndicator[idx] != null && cacheMyCustomIndicator[idx].Period == period && cacheMyCustomIndicator[idx].EqualsInput(input))
    						return cacheMyCustomIndicator[idx];
    			return CacheIndicator<MyCustomIndicator>(new MyCustomIndicator(){ Period = period }, input, ref cacheMyCustomIndicator);
    		}
    	}
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    	public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    	{
    		public Indicators.MyCustomIndicator MyCustomIndicator(int period)
    		{
    			return indicator.MyCustomIndicator(Input, period);
    		}
    
    		public Indicators.MyCustomIndicator MyCustomIndicator(ISeries<double> input , int period)
    		{
    			return indicator.MyCustomIndicator(input, period);
    		}
    	}
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
    	public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    	{
    		public Indicators.MyCustomIndicator MyCustomIndicator(int period)
    		{
    			return indicator.MyCustomIndicator(Input, period);
    		}
    
    		public Indicators.MyCustomIndicator MyCustomIndicator(ISeries<double> input , int period)
    		{
    			return indicator.MyCustomIndicator(input, period);
    		}
    	}
    }
    
    #endregion
    https://www.google.com/search?safe=o...onfigure+state.

    Comment


      #3
      I read thro all the forums before posting this thread....,.
      I have my code running only when the state=State.realtime. there is a implicit assumption that the market data is already loaded when this happens. so the only theory I have is that there is a bug in the NT core. this is why I created a simple representation of the problem so the NT folks can see the problem and fix it.

      Comment


        #4
        Hello junkone, and thank you for your question.

        I noticed your code relies on the proprietary file STSVer2.cs . Would it be possible for you to prepare code samples that do not rely on this? If not, and this is an indicator you own the rights to, would you be willing to send a copy to platformsupport[at]ninjatrader[dot]com referencing this unique number in the body of your e-mail : 1518806 ? If neither of these is possible, we will not be able to use your code sample, as we can not get it to compile in our end. In this event, could you generally describe in plain language what we would need to do to reproduce this?

        Thank you for helping us make NinjaTrader 8 better.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by faustf, Today, 05:00 AM
        0 responses
        5 views
        0 likes
        Last Post faustf
        by faustf
         
        Started by NinjaCustomer, Today, 03:19 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChrisSch  
        Started by MarianApalaghiei, Today, 02:54 AM
        1 response
        5 views
        0 likes
        Last Post MarianApalaghiei  
        Started by RandanAL, Yesterday, 11:58 PM
        0 responses
        5 views
        0 likes
        Last Post RandanAL  
        Started by Kabua, Yesterday, 11:24 PM
        0 responses
        5 views
        0 likes
        Last Post Kabua
        by Kabua
         
        Working...
        X