Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi!
Is there someone who can put in a peace of code in this to get a sound alert?
It is NarrowestRangeFinder.
Thanks,
gollum
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
[Description("This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.")]
public class NarrowestRangeFinder : Indicator
{
#region Variables
// Wizard generated variables
private int period = 4; // Default setting for PatternLength
private Color patternColor = Color.Blue; // Default setting for Paint Bar Color
private bool insidePattern = false;
// User defined variables (add any user defined variables below)
#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()
{
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar < period)
return;
for (int index = 0; index < period; index++)
{
if (Range()[0] > Range()[index])
break;
if (index == period - 1)
BarColor = patternColor;
}
}
#region Properties
[XmlIgnore()]
[Description("Length of the narrowest range pattern")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(2, value); }
}
[XmlIgnore()]
[Description("Include inside pattern")]
[Category("Parameters")]
public bool InsidePattern
{
get { return insidePattern; }
set { insidePattern = value; }
}
[XmlIgnore()]
[Description("PaintBarColor")]
[Category("Parameters")]
public Color PatternColor
{
get { return patternColor; }
set { patternColor = value; }
}
// Serialize our Color object
[Browsable(false)]
public string PatternColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(patternColor); }
set { patternColor = NinjaTrader.Gui.Design.SerializableColor.FromString(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 NarrowestRangeFinder[] cacheNarrowestRangeFinder = null;
private static NarrowestRangeFinder checkNarrowestRangeFinder = new NarrowestRangeFinder();
/// <summary>
/// This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
/// <returns></returns>
public NarrowestRangeFinder NarrowestRangeFinder(bool insidePattern, Color patternColor, int period)
{
return NarrowestRangeFinder(Input, insidePattern, patternColor, period);
}
/// <summary>
/// This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
/// <returns></returns>
public NarrowestRangeFinder NarrowestRangeFinder(Data.IDataSeries input, bool insidePattern, Color patternColor, int period)
{
if (cacheNarrowestRangeFinder != null)
for (int idx = 0; idx < cacheNarrowestRangeFinder.Length; idx++)
if (cacheNarrowestRangeFinder[idx].InsidePattern == insidePattern && cacheNarrowestRangeFinder[idx].PatternColor == patternColor && cacheNarrowestRangeFinder[idx].Period == period && cacheNarrowestRangeFinder[idx].EqualsInput(input))
return cacheNarrowestRangeFinder[idx];
// 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 indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.NarrowestRangeFinder NarrowestRangeFinder(bool insidePattern, Color patternColor, int period)
{
return _indicator.NarrowestRangeFinder(Input, insidePattern, patternColor, period);
}
/// <summary>
/// This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
/// <returns></returns>
public Indicator.NarrowestRangeFinder NarrowestRangeFinder(Data.IDataSeries input, bool insidePattern, Color patternColor, int period)
{
return _indicator.NarrowestRangeFinder(input, insidePattern, patternColor, period);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.NarrowestRangeFinder NarrowestRangeFinder(bool insidePattern, Color patternColor, int period)
{
return _indicator.NarrowestRangeFinder(Input, insidePattern, patternColor, period);
}
/// <summary>
/// This indicator will show you the narrowest range over the specified pattern length input, you can also select to only highlight those patterns where an inside bar is present, too.
/// </summary>
/// <returns></returns>
public Indicator.NarrowestRangeFinder NarrowestRangeFinder(Data.IDataSeries input, bool insidePattern, Color patternColor, 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");
Since you didn't specify when or based on what condition you want the sound to play, the simple answer is to just use the PlaySound() Ninjascript function to play a sound in the right place in your code, somewhere in OnBarUpdate() I presume..
Hi and thanks for the quick answer!
Firstly, I have no experience in C # programming.
The code is taken directly from the Indicator cited above, do not know who devised it, but thanks.
I want an alert function in indicator's settings so that you can select an audio file.
Not more than that ....