Skip to content

Instantly share code, notes, and snippets.

@zundra
Created December 16, 2021 16:31
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 zundra/964ce4a596a70aec5165ab1954fd6a72 to your computer and use it in GitHub Desktop.
Save zundra/964ce4a596a70aec5165ab1954fd6a72 to your computer and use it in GitHub Desktop.
Delta Test
namespace NinjaTrader.NinjaScript.Indicators
{
public class DeltaTest : Indicator
{
private OrderFlowCumulativeDelta CD;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "DeltaTest";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = false;
DrawOnPricePanel = true;
PaintPriceMarkers = false;
IsSuspendedWhileInactive = true;
IsAutoScale = false;
}
else if(State == State.DataLoaded)
{
CD = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0);
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Tick, 1);
}
else if (State == State.Historical)
{
if (Calculate == Calculate.OnPriceChange)
{
Draw.TextFixed(this, "NinjaScriptInfo", string.Format(NinjaTrader.Custom.Resource.NinjaScriptOnPriceChangeError, Name), TextPosition.BottomRight);
Log(string.Format(NinjaTrader.Custom.Resource.NinjaScriptOnPriceChangeError, Name), LogLevel.Error);
}
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
Draw.Text(this, "close" + CurrentBar, ""+ CD.DeltaClose[0], 0, Low[0] - 30);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment