Skip to content

Instantly share code, notes, and snippets.

@DexterHaslem
Created February 20, 2015 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DexterHaslem/a148696d403099c345cd to your computer and use it in GitHub Desktop.
Save DexterHaslem/a148696d403099c345cd to your computer and use it in GitHub Desktop.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
namespace NinjaTrader.Indicator
{
[Description("Enter the description of your new custom indicator here")]
public class PrintBidAsk : Indicator
{
protected override void Initialize()
{
Overlay = false;
Add(new Plot(Color.Red, "fart"));
}
protected override void OnBarUpdate() { Print("OBU"); Value.Set(Close[0]); }
protected override void OnMarketData(MarketDataEventArgs e)
{
Print("OMD");
//if (e.MarketDataType == MarketDataType.Bid || e.MarketDataType == MarketDataType.Ask)
// Print(e.ToString());
}
}
}
#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 PrintBidAsk[] cachePrintBidAsk = null;
private static PrintBidAsk checkPrintBidAsk = new PrintBidAsk();
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public PrintBidAsk PrintBidAsk()
{
return PrintBidAsk(Input);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public PrintBidAsk PrintBidAsk(Data.IDataSeries input)
{
if (cachePrintBidAsk != null)
for (int idx = 0; idx < cachePrintBidAsk.Length; idx++)
if (cachePrintBidAsk[idx].EqualsInput(input))
return cachePrintBidAsk[idx];
lock (checkPrintBidAsk)
{
if (cachePrintBidAsk != null)
for (int idx = 0; idx < cachePrintBidAsk.Length; idx++)
if (cachePrintBidAsk[idx].EqualsInput(input))
return cachePrintBidAsk[idx];
PrintBidAsk indicator = new PrintBidAsk();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
Indicators.Add(indicator);
indicator.SetUp();
PrintBidAsk[] tmp = new PrintBidAsk[cachePrintBidAsk == null ? 1 : cachePrintBidAsk.Length + 1];
if (cachePrintBidAsk != null)
cachePrintBidAsk.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cachePrintBidAsk = 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>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.PrintBidAsk PrintBidAsk()
{
return _indicator.PrintBidAsk(Input);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.PrintBidAsk PrintBidAsk(Data.IDataSeries input)
{
return _indicator.PrintBidAsk(input);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.PrintBidAsk PrintBidAsk()
{
return _indicator.PrintBidAsk(Input);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.PrintBidAsk PrintBidAsk(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.PrintBidAsk(input);
}
}
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment