| |
 |
Views:
2332 |
| Added: July 29, 2009 |
| |
| |
|
| This formula has not been rated yet |
|
|
| |
email this link
|
| |
| |
| Tags:
NinjaTrader, indicator
|
| |
 |
Code:
/* This indicator is a translation of a public-domain indictor that was
rewritten for Ninja Trader
TazaTek maintains copyright of this version, but places it into
the public domain for private use.
For more great NinjaTrader indicators, and to request your favorite,
please visit:
******* www.TazaTek.com **********
*************************************** */
#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
{
///
/// www.TazaTek.com True Range
///
[Description("www.TazaTek.com True Range")]
public class TazaTR : Indicator
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
private double v1=0;
private double v2=0;
private double v3=0;
private double result=0;
#endregion
///
/// This method is used to configure the indicator and is called once before any bar data is loaded.
///
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "TR_Plot"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
if (CurrentBar < 2) { result = 0;}
else {
v1=High[0] - Low[0];
v2=Math.Abs(High[0] - Close[1]);
v3=Math.Abs(Low[0] - Close[1]);
if( (v1 > v2) && (v1 > v3)) { result = v1;}
else if( (v2>v1) && (v2 > v3)) {result=v2;}
else {result = v3;}
}
TR_Plot.Set(result);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries TR_Plot
{
get { return Values[0]; }
}
#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 TazaTR[] cacheTazaTR = null;
private static TazaTR checkTazaTR = new TazaTR();
///
/// www.TazaTek.com True Range
///
///
public TazaTR TazaTR()
{
return TazaTR(Input);
}
///
/// www.TazaTek.com True Range
///
///
public TazaTR TazaTR(Data.IDataSeries input)
{
if (cacheTazaTR != null)
for (int idx = 0; idx < cacheTazaTR.Length; idx++)
if (cacheTazaTR[idx].EqualsInput(input))
return cacheTazaTR[idx];
TazaTR indicator = new TazaTR();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.SetUp();
TazaTR[] tmp = new TazaTR[cacheTazaTR == null ? 1 : cacheTazaTR.Length + 1];
if (cacheTazaTR != null)
cacheTazaTR.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheTazaTR = 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
{
///
/// www.TazaTek.com True Range
///
///
[Gui.Design.WizardCondition("Indicator")]
public Indicator.TazaTR TazaTR()
{
return _indicator.TazaTR(Input);
}
///
/// www.TazaTek.com True Range
///
///
public Indicator.TazaTR TazaTR(Data.IDataSeries input)
{
return _indicator.TazaTR(input);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
///
/// www.TazaTek.com True Range
///
///
[Gui.Design.WizardCondition("Indicator")]
public Indicator.TazaTR TazaTR()
{
return _indicator.TazaTR(Input);
}
///
/// www.TazaTek.com True Range
///
///
public Indicator.TazaTR TazaTR(Data.IDataSeries input)
{
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.TazaTR(input);
}
}
}
#endregion
Code to difficult? Find somebody to help you with coding here.
Source: www.TazaTek.com
all formulas for NinjaTrader
all formulas
|