It compiles and charts OK, but trying to save the workspace gives the error The Indicator DMmine could not be serialized and to look at Help, but I cant find serialized in any search.
What does it mean?
// // Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>. // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release. // #region Using declarations using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { /// <summary> /// Directional Movement (DMmine). This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> [Description("This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside.")] public class DMmine : Indicator { #region Variables private int period = 14; private DataSeries dmPlus; private DataSeries dmMinus; private DataSeries sumDmPlus; private DataSeries sumDmMinus; private DataSeries sumTr; private DataSeries tr; #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(new Plot(new Pen(Color.Black, 3), "ADX")); Add(new Plot(Color.Green, "+DI")); Add(new Plot(Color.Red, "-DI")); Add(new Line(Color.Black, 20, "20")); Add(new Line(Color.Blue, 25, "25")); Add(new Line(Color.Crimson, 30, "30")); dmPlus = new DataSeries(this); dmMinus = new DataSeries(this); sumDmPlus = new DataSeries(this); sumDmMinus = new DataSeries(this); sumTr = new DataSeries(this); tr = new DataSeries(this); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { double trueRange = High[0] - Low[0]; if (CurrentBar == 0) { tr.Set(trueRange); dmPlus.Set(0); dmMinus.Set(0); sumTr.Set(tr[0]); sumDmPlus.Set(dmPlus[0]); sumDmMinus.Set(dmMinus[0]); Value.Set(50); } else { tr.Set(Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(trueRange, Math.Abs(High[0] - Close[1])))); dmPlus.Set(High[0] - High[1] > Low[1] - Low[0] ? Math.Max(High[0] - High[1], 0) : 0); dmMinus.Set(Low[1] - Low[0] > High[0] - High[1] ? Math.Max(Low[1] - Low[0], 0) : 0); if (CurrentBar < Period) { sumTr.Set(sumTr[1] + tr[0]); sumDmPlus.Set(sumDmPlus[1] + dmPlus[0]); sumDmMinus.Set(sumDmMinus[1] + dmMinus[0]); } else { sumTr.Set(sumTr[1] - sumTr[1] / Period + tr[0]); sumDmPlus.Set(sumDmPlus[1] - sumDmPlus[1] / Period + dmPlus[0]); sumDmMinus.Set(sumDmMinus[1] - sumDmMinus[1] / Period + dmMinus[0]); } double diPlus = 100 * (sumTr[0] == 0 ? 0 : sumDmPlus[0] / sumTr[0]); double diMinus = 100 * (sumTr[0] == 0 ? 0 : sumDmMinus[0] / sumTr[0]); double diff = Math.Abs(diPlus - diMinus); double sum = diPlus + diMinus; Value.Set(sum == 0 ? 50 : ((Period - 1) * Value[1] + 100 * diff / sum) / Period); DiPlus.Set(diPlus); DiMinus.Set(diMinus); } } #region Properties /// <summary> /// </summary> [Browsable(false)] [XmlIgnore()] public DataSeries DiPlus { get { return Values[1]; } } /// <summary> /// </summary> [Browsable(false)] [XmlIgnore()] public DataSeries DiMinus { get { return Values[2]; } } /// <summary> /// </summary> [Description("Numbers of bars used for calculations")] [Category("Parameters")] public int Period { get { return period; } set { period = Math.Max(1, value); } } #endregion } } #region NinjaScript generated code. Neither change nor remove. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { public partial class Indicator : IndicatorBase { private DMmine[] cacheDMmine = null; private static DMmine checkDMmine = new DMmine(); /// <summary> /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> /// <returns></returns> public DMmine DMmine(int period) { return DMmine(Input, period); } /// <summary> /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> /// <returns></returns> public DMmine DMmine(Data.IDataSeries input, int period) { checkDMmine.Period = period; period = checkDMmine.Period; if (cacheDMmine != null) for (int idx = 0; idx < cacheDMmine.Length; idx++) if (cacheDMmine[idx].Period == period && cacheDMmine[idx].EqualsInput(input)) return cacheDMmine[idx]; DMmine indicator = new DMmine(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; indicator.Input = input; indicator.Period = period; indicator.SetUp(); DMmine[] tmp = new DMmine[cacheDMmine == null ? 1 : cacheDMmine.Length + 1]; if (cacheDMmine != null) cacheDMmine.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheDMmine = tmp; Indicators.Add(indicator); return indicator; } } } // This namespace holds all market analyzer column definitions and is required. Do not change it. namespace NinjaTrader.MarketAnalyzer { public partial class Column : ColumnBase { /// <summary> /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.DMmine DMmine(int period) { return _indicator.DMmine(Input, period); } /// <summary> /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> /// <returns></returns> public Indicator.DMmine DMmine(Data.IDataSeries input, int period) { return _indicator.DMmine(input, period); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// <summary> /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.DMmine DMmine(int period) { return _indicator.DMmine(Input, period); } /// <summary> /// This is the same indicator as the ADX, with the addition of the two directional movement indicators +DI and -DI. +DI and -DI measure upward and downward momentum. A buy signal is generated when +DI crosses -DI to the upside. A sell signal is generated when -DI crosses +DI to the downside. /// </summary> /// <returns></returns> public Indicator.DMmine DMmine(Data.IDataSeries input, int period) { if (InInitialize && input == null) throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method"); return _indicator.DMmine(input, period); } } } #endregion
[Browsable(false)] [XmlIgnore()] public DataSeries DiPlus { get { return Values[0]; } } /// [COLOR=#000080]<summary>[/COLOR] /// [COLOR=#000080]</summary>[/COLOR] [Browsable(false)] [XmlIgnore()] public DataSeries DiMinus { get { return Values[1]; } }
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by geddyisodin, Today, 05:20 AM
|
1 response
11 views
0 likes
|
Last Post Today, 07:38 AM | ||
Started by Max238, Today, 01:28 AM
|
3 responses
33 views
0 likes
|
Last Post
by Max238
Today, 07:36 AM
|
||
Started by timko, Today, 06:45 AM
|
2 responses
13 views
0 likes
|
Last Post Today, 07:30 AM | ||
Started by habeebft, Today, 07:27 AM
|
0 responses
6 views
0 likes
|
Last Post
by habeebft
Today, 07:27 AM
|
||
Started by Tim-c, Today, 03:54 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:26 AM |
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.
Comment