log in     sign up for free
 
Whenever you get hit, you are very upset emotionally. Most traders try to make it back immediately; they try to play bigger. Whenever you try to get all your losses back at once, you are most often doomed to fail.
Marty Schwartz
 
 
Home
systems (285)
 
 
Special offer: buy AmiBroker and EOD+Real-Time Data
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

True Range

Formula for: NinjaTrader

indicator

 

 

Views:  2332

Added: July 29, 2009
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
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

 

View similar (indicator for NinjaTrader):

True Range
...
 
 
all formulas for NinjaTrader
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
PayPalSecure payments by PayPal S4T™ is a part of TAURO EDUCATION NETWORK
 
Privacy note | (c) copyrights systems4trading.com 2006-2009