• 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

Public Series<bool> reference throwing CS0103 "Does not exist in current context"

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

    Public Series<bool> reference throwing CS0103 "Does not exist in current context"

    Hi,
    I am converting an indicator from NT7 to NT8. I am almost there but I cannot find a solution for the last issue that I'm having which is a CS0103 error about a Series<bool> that I have already made public in Properties. I have posted the code below. Thanks for any help you can provide.

    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.MackPATS
    {
        public class MackPATRisk : Indicator
        {
            private Series<bool> riskTo1;
            private int riskDollar = 100;
            private double rangeTicks = 0;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"This indicator provides the value of the bar range and the risk amount in dollars for this bar";
                    Name                                        = "MackPATRisk";
                    Calculate                                    = Calculate.OnEachTick;
                    IsOverlay                                    = true;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = true;
                    DrawHorizontalGridLines                        = false;
                    DrawVerticalGridLines                        = false;
                    PaintPriceMarkers                            = false;
                    IsAutoScale                                    = false;
                    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;
                    // riskDollar                    = 100;
                    // rangeTicks                    = 0;
                    AddPlot(new Stroke(Brushes.Firebrick, 2), PlotStyle.Bar, "RangeValue");
                    AddPlot(new Stroke(Brushes.DarkGoldenrod, 2), PlotStyle.Dot, "RiskAmt");
                }
                else if (State == State.Configure)
                {
                }
                else if (State == State.DataLoaded)
                {                
                    riskTo1 = new Series<bool>(this);
                }
            }
    
            protected override void OnBarUpdate()
            {
                rangeTicks = (High[0] - Low[0])/TickSize;
                RangeValue[0] = rangeTicks;
                    double risk = Instrument.MasterInstrument.RoundToTickSize((High[0] - Low[0]) + 3*TickSize) * Instrument.MasterInstrument.PointValue;
                    RiskAmt[0] = risk;
    
                if ( risk <= riskDollar ) {
                    RiskTol[0] = true; }
                    else {
                    RiskTol[0] = false; }
            }
    
            #region Properties
            [NinjaScriptProperty]
            [Range(1, int.MaxValue)]
            [Display(Name="RiskDollar", Description="risk amount for the trade", Order=1, GroupName="Parameters")]
            public int RiskDollar
            {
                get { return riskDollar; }
                set { riskDollar = Math.Max(1, value); }
            }
    
            [NinjaScriptProperty]
            [Range(0, double.MaxValue)]
            [Display(Name="RangeTicks", Order=2, GroupName="Parameters")]
            public double RangeTicks
            { get; set; }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> RangeValue
            {
                get { return Values[0]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> RiskAmt
            {
                get { return Values[1]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<bool> RiskTo1
            {
                get { return riskTo1; }
            }
            #endregion
    
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private MackPATS.MackPATRisk[] cacheMackPATRisk;
            public MackPATS.MackPATRisk MackPATRisk(int riskDollar, double rangeTicks)
            {
                return MackPATRisk(Input, riskDollar, rangeTicks);
            }
    
            public MackPATS.MackPATRisk MackPATRisk(ISeries<double> input, int riskDollar, double rangeTicks)
            {
                if (cacheMackPATRisk != null)
                    for (int idx = 0; idx < cacheMackPATRisk.Length; idx++)
                        if (cacheMackPATRisk[idx] != null && cacheMackPATRisk[idx].RiskDollar == riskDollar && cacheMackPATRisk[idx].RangeTicks == rangeTicks && cacheMackPATRisk[idx].EqualsInput(input))
                            return cacheMackPATRisk[idx];
                return CacheIndicator<MackPATS.MackPATRisk>(new MackPATS.MackPATRisk(){ RiskDollar = riskDollar, RangeTicks = rangeTicks }, input, ref cacheMackPATRisk);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.MackPATS.MackPATRisk MackPATRisk(int riskDollar, double rangeTicks)
            {
                return indicator.MackPATRisk(Input, riskDollar, rangeTicks);
            }
    
            public Indicators.MackPATS.MackPATRisk MackPATRisk(ISeries<double> input , int riskDollar, double rangeTicks)
            {
                return indicator.MackPATRisk(input, riskDollar, rangeTicks);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.MackPATS.MackPATRisk MackPATRisk(int riskDollar, double rangeTicks)
            {
                return indicator.MackPATRisk(Input, riskDollar, rangeTicks);
            }
    
            public Indicators.MackPATS.MackPATRisk MackPATRisk(ISeries<double> input , int riskDollar, double rangeTicks)
            {
                return indicator.MackPATRisk(input, riskDollar, rangeTicks);
            }
        }
    }
    
    #endregion
    6.5.0

    #2
    Hello HombreLobo,

    In what you provided you never declared a series named RiskTol, you did make one named RiskTo1. It looks like this is just a spelling problem here you used an L instead of a 1.


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

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello HombreLobo,

      In what you provided you never declared a series named RiskTol, you did make one named RiskTo1. It looks like this is just a spelling problem here you used an L instead of a 1.


      I look forward to being of further assistance.
      Wow, I'm an idiot haha. Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by [email protected], Today, 10:54 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by wbennettjr, Today, 11:18 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by Induna, Today, 05:38 AM
      2 responses
      6 views
      0 likes
      Last Post Induna
      by Induna
       
      Started by Alfred, Today, 10:20 AM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by emuns, Today, 10:34 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X