ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Fractal Trading Indicator

<< < (3/3)

Renegade:
@Niceperson: I added code tags around your code snippet for readability.
@Renegade: Line 47 was the red coloured line before I added the code tags.
-skwire (November 01, 2011, 11:41 PM)
--- End quote ---

Thanks for that.


For the code, you have sound now, so that's good. It's just in the wrong spot.

Comment out that line by placing "//" at the front of it. That will disable it.

Next, sift through the various methods and see if you can read enough of the names of variables to find an "alert". When you find that, paste in the sound code that you'd commented out before. (Make sure it's not still commented out.)

Test to see if you've put it in the right place. If not, look around again and repeat.

Make sure to search for "alert" in the code as that should be faster & easier than just reading through. Do make sure to skim it though for words that you recognize as possibly being relevant.

Niceperson:
Hello,

You are right that the code has to be placed in the right spot. I searched through the complete code file, but did not find any "alert" line. I have also attached the complete code file, syntax highlighted.

Please note that the code in Line 31 has been commented out because it gives sound on each tick.  Codes from line 106 are auto generated by Ninja system. I have just added them here for completeness.


Thanks



--- Code: Text ---#region Using declarationsusing System;using System.Diagnostics;using System.Drawing;using System.Drawing.Drawing2D;using System.ComponentModel;using System.Xml.Serialization;using NinjaTrader.Cbi;using NinjaTrader.Data;using NinjaTrader.Gui.Chart;#endregion namespace NinjaTrader.Indicator{    [Description("")]    [Gui.Design.DisplayName("FractalPivot (TradeStation)")]    public class FractalPivot_TradeStation : Indicator    {        #region Variables                private int pLeftStrength = 2;                private int pRightStrength = 2;                private int pTickSeparation = 3;        #endregion                                         protected override void Initialize()        {                        Add(new Plot(new Pen(Color.Red,12), PlotStyle.TriangleDown, "Highs"));                                                          Add(new Plot(new Pen(Color.Blue,12), PlotStyle.TriangleUp, "Lows"));                                    //PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");                        CalculateOnBarClose     = false;            Overlay                             = true;            PriceTypeSupported  = false;        }         protected override void OnBarUpdate()        {                        if(CurrentBar < Math.Max((pLeftStrength+pRightStrength)*3,15))                                return;                         if(pType == FractalPivot_TradeStation_Type.Both || pType == FractalPivot_TradeStation_Type.Highs) {                                int bar = (int)Pivot_EasyLanguage(1, 1, pLeftStrength, pRightStrength+1, pRightStrength).PivotBarRelative[0];                                                                if(bar>=0) Values[0].Set(pRightStrength, High[pRightStrength]+TickSize * pTickSeparation);                                                                                        }                        if(pType == FractalPivot_TradeStation_Type.Both || pType == FractalPivot_TradeStation_Type.Lows) {                                int bar = (int)Pivot_EasyLanguage(-1, 1, pLeftStrength, pRightStrength+1, pRightStrength).PivotBarRelative[0];                                                                if(bar>=0) Values[1].Set(pRightStrength, Low[pRightStrength]-TickSize * pTickSeparation);                                                        }        }                                                                 //====================================================================                #region Properties                 [Description("Ticks separation from bar")]                [Category("Visual")]                public int TickSeparation                {                        get { return pTickSeparation; }                        set { pTickSeparation = Math.Max(1,value); }                }                 [Description("Left strength")]                [Category("Parameters")]                public int LeftStrength                {                        get { return pLeftStrength; }                        set { pLeftStrength = Math.Max(1,value); }                }                 [Description("Right strength")]                [Category("Parameters")]                public int RightStrength                {                        get { return pRightStrength; }                        set { pRightStrength = Math.Max(1,value); }                }                                private FractalPivot_TradeStation_Type pType = FractalPivot_TradeStation_Type.Both;                [Description("High prices, Low prices, or both")]                [Category("Parameters")]                public FractalPivot_TradeStation_Type Type                {                        get { return pType; }                        set { pType = value; }                }                                #endregion        }}public enum FractalPivot_TradeStation_Type {        Highs,        Lows,        Both} #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 FractalPivot_TradeStation[] cacheFractalPivot_TradeStation = null;         private static FractalPivot_TradeStation checkFractalPivot_TradeStation = new FractalPivot_TradeStation();         /// <summary>        ///         /// </summary>        /// <returns></returns>        public FractalPivot_TradeStation FractalPivot_TradeStation(int leftStrength, int rightStrength, FractalPivot_TradeStation_Type type)        {            return FractalPivot_TradeStation(Input, leftStrength, rightStrength, type);        }         /// <summary>        ///         /// </summary>        /// <returns></returns>        public FractalPivot_TradeStation FractalPivot_TradeStation(Data.IDataSeries input, int leftStrength, int rightStrength, FractalPivot_TradeStation_Type type)        {            if (cacheFractalPivot_TradeStation != null)                for (int idx = 0; idx < cacheFractalPivot_TradeStation.Length; idx++)                    if (cacheFractalPivot_TradeStation[idx].LeftStrength == leftStrength && cacheFractalPivot_TradeStation[idx].RightStrength == rightStrength && cacheFractalPivot_TradeStation[idx].Type == type && cacheFractalPivot_TradeStation[idx].EqualsInput(input))                        return cacheFractalPivot_TradeStation[idx];             lock (checkFractalPivot_TradeStation)            {                checkFractalPivot_TradeStation.LeftStrength = leftStrength;                leftStrength = checkFractalPivot_TradeStation.LeftStrength;                checkFractalPivot_TradeStation.RightStrength = rightStrength;                rightStrength = checkFractalPivot_TradeStation.RightStrength;                checkFractalPivot_TradeStation.Type = type;                type = checkFractalPivot_TradeStation.Type;                 if (cacheFractalPivot_TradeStation != null)                    for (int idx = 0; idx < cacheFractalPivot_TradeStation.Length; idx++)                        if (cacheFractalPivot_TradeStation[idx].LeftStrength == leftStrength && cacheFractalPivot_TradeStation[idx].RightStrength == rightStrength && cacheFractalPivot_TradeStation[idx].Type == type && cacheFractalPivot_TradeStation[idx].EqualsInput(input))                            return cacheFractalPivot_TradeStation[idx];                 FractalPivot_TradeStation indicator = new FractalPivot_TradeStation();                indicator.BarsRequired = BarsRequired;                indicator.CalculateOnBarClose = CalculateOnBarClose;#if NT7                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;                indicator.MaximumBarsLookBack = MaximumBarsLookBack;#endif                indicator.Input = input;                indicator.LeftStrength = leftStrength;                indicator.RightStrength = rightStrength;                indicator.Type = type;                Indicators.Add(indicator);                indicator.SetUp();                 FractalPivot_TradeStation[] tmp = new FractalPivot_TradeStation[cacheFractalPivot_TradeStation == null ? 1 : cacheFractalPivot_TradeStation.Length + 1];                if (cacheFractalPivot_TradeStation != null)                    cacheFractalPivot_TradeStation.CopyTo(tmp, 0);                tmp[tmp.Length - 1] = indicator;                cacheFractalPivot_TradeStation = tmp;                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>        ///         /// </summary>        /// <returns></returns>        [Gui.Design.WizardCondition("Indicator")]        public Indicator.FractalPivot_TradeStation FractalPivot_TradeStation(int leftStrength, int rightStrength, FractalPivot_TradeStation_Type type)        {            return _indicator.FractalPivot_TradeStation(Input, leftStrength, rightStrength, type);        }         /// <summary>        ///         /// </summary>        /// <returns></returns>        public Indicator.FractalPivot_TradeStation FractalPivot_TradeStation(Data.IDataSeries input, int leftStrength, int rightStrength, FractalPivot_TradeStation_Type type)        {            return _indicator.FractalPivot_TradeStation(input, leftStrength, rightStrength, type);        }    }} // This namespace holds all strategies and is required. Do not change it.namespace NinjaTrader.Strategy{    public partial class Strategy : StrategyBase    {        /// <summary>        ///         /// </summary>        /// <returns></returns>        [Gui.Design.WizardCondition("Indicator")]        public Indicator.FractalPivot_TradeStation FractalPivot_TradeStation(int leftStrength, int rightStrength, FractalPivot_TradeStation_Type type)        {            return _indicator.FractalPivot_TradeStation(Input, leftStrength, rightStrength, type);        }         /// <summary>        ///         /// </summary>        /// <returns></returns>        public Indicator.FractalPivot_TradeStation FractalPivot_TradeStation(Data.IDataSeries input, int leftStrength, int rightStrength, FractalPivot_TradeStation_Type type)        {            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.FractalPivot_TradeStation(input, leftStrength, rightStrength, type);        }    }}#endregion

Curt:
you can enable / disable specific sounds under Tools > Options > General  in your Control Center-NinjaTrader Support
--- End quote ---

-but maybe this option is missing if you are running the free version?

If you search their site and keep an eye on new feature development, you may want to look for "enhancement # 1254" (new audio settings).

Navigation

[0] Message Index

[*] Previous page

Go to full version