NexusFi: Find Your Edge


Home Menu

 





Inside bar alert


Discussion in NinjaTrader

Updated
    1. trending_up 2,234 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread

Inside bar alert

  #1 (permalink)
gollum
Stockholm i mina t/%%Ybg BBb
 
Posts: 3 since Oct 2011
Thanks Given: 1
Thanks Received: 0

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;

if (insidePattern && High[0] >= High[1] || Low[0] <= Low[1])
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];

lock (checkNarrowestRangeFinder)
{
checkNarrowestRangeFinder.InsidePattern = insidePattern;
insidePattern = checkNarrowestRangeFinder.InsidePattern;
checkNarrowestRangeFinder.PatternColor = patternColor;
patternColor = checkNarrowestRangeFinder.PatternColor;
checkNarrowestRangeFinder.Period = period;
period = checkNarrowestRangeFinder.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];

NarrowestRangeFinder indicator = new NarrowestRangeFinder();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
indicator.InsidePattern = insidePattern;
indicator.PatternColor = patternColor;
indicator.Period = period;
Indicators.Add(indicator);
indicator.SetUp();

NarrowestRangeFinder[] tmp = new NarrowestRangeFinder[cacheNarrowestRangeFinder == null ? 1 : cacheNarrowestRangeFinder.Length + 1];
if (cacheNarrowestRangeFinder != null)
cacheNarrowestRangeFinder.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheNarrowestRangeFinder = 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>
/// 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");

return _indicator.NarrowestRangeFinder(input, insidePattern, patternColor, period);
}
}
}
#endregion

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #3 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709


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..

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #4 (permalink)
gollum
Stockholm i mina t/%%Ybg BBb
 
Posts: 3 since Oct 2011
Thanks Given: 1
Thanks Received: 0

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 ....

gollum

Reply With Quote
  #5 (permalink)
gollum
Stockholm i mina t/%%Ybg BBb
 
Posts: 3 since Oct 2011
Thanks Given: 1
Thanks Received: 0

of course the alarm triggered when an inside bar formed according to the settings selected in the indicator ..

Reply With Quote




Last Updated on August 30, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts