-
-
Save zundra/964ce4a596a70aec5165ab1954fd6a72 to your computer and use it in GitHub Desktop.
Delta Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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