Has anyone developed an indicator much like MAX and MIN that applies to volume?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Volume High/Low.
Collapse
X
-
Hi, which indicator are looking to edit? Just right click in the system one and save the code under a new name for modification...you can take a look at those volume based files from our sharing for coding ideas and workarounds - http://www.ninjatrader-support2.com/...=volume&desc=1BertrandNinjaTrader Customer Service
Comment
-
Hey Killer Bs,
Here's the code but I don't know where to change the inputs so it read volume instead of price.
//
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
[Description("The Maximum shows the maximum of the last n bars.")]
public class MAX : Indicator
{
#region Variables
private int period = 14;
#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()
{
Add(new Plot(Color.Green, "MAX"));
Overlay = true;
PriceTypeSupported = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
double val = double.MinValue;
for (int barsBack = Math.Min(CurrentBar, Period - 1); barsBack >= 0; barsBack--)
val = Math.Max(val, Input[barsBack]);
Value.Set(val);
}
#region Properties
/// <summary>
/// </summary>
[Description("Numbers of bars used for calculations")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, 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 MAX[] cacheMAX = null;
private static MAX checkMAX = new MAX();
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
/// <returns></returns>
public MAX MAX(int period)
{
return MAX(Input, period);
}
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
/// <returns></returns>
public MAX MAX(Data.IDataSeries input, int period)
{
checkMAX.Period = period;
period = checkMAX.Period;
if (cacheMAX != null)
for (int idx = 0; idx < cacheMAX.Length; idx++)
if (cacheMAX[idx].Period == period && cacheMAX[idx].EqualsInput(input))
return cacheMAX[idx];
MAX indicator = new MAX();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.Period = period;
indicator.SetUp();
MAX[] tmp = new MAX[cacheMAX == null ? 1 : cacheMAX.Length + 1];
if (cacheMAX != null)
cacheMAX.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheMAX = 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
{
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MAX MAX(int period)
{
return _indicator.MAX(Input, period);
}
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
/// <returns></returns>
public Indicator.MAX MAX(Data.IDataSeries input, int period)
{
return _indicator.MAX(input, period);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MAX MAX(int period)
{
return _indicator.MAX(Input, period);
}
/// <summary>
/// The Maximum shows the maximum of the last n bars.
/// </summary>
/// <returns></returns>
public Indicator.MAX MAX(Data.IDataSeries input, 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.MAX(input, period);
}
}
}
#endregion
Do I tie the inputs to volume? How would I go about doing that?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
15 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by flybuzz, 04-21-2024, 04:07 PM
|
17 responses
229 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:45 PM
|
||
Started by agclub, 04-21-2024, 08:57 PM
|
3 responses
17 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:42 PM
|
||
Started by TradingLoss, 04-21-2024, 04:32 PM
|
4 responses
45 views
2 likes
|
Last Post
by TradingLoss
Yesterday, 11:40 PM
|
||
Started by cre8able, 04-17-2024, 04:16 PM
|
6 responses
57 views
0 likes
|
Last Post
by cre8able
Yesterday, 09:20 PM
|
Comment