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

  • HombreLobo
    replied
    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.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    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.

    Leave a comment:


  • 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

Latest Posts

Collapse

Topics Statistics Last Post
Started by jeanne, Today, 02:41 AM
2 responses
11 views
0 likes
Last Post NinjaTrader_Marco  
Started by patricia70, Today, 03:40 AM
0 responses
5 views
0 likes
Last Post patricia70  
Started by patricia70, Today, 03:04 AM
0 responses
6 views
0 likes
Last Post patricia70  
Started by Cassius Romarius, Today, 02:41 AM
1 response
5 views
0 likes
Last Post s.kinra
by s.kinra
 
Started by Mindset, Today, 02:00 AM
0 responses
6 views
0 likes
Last Post Mindset
by Mindset
 
Working...
X