Resolve off-by-one error when drawing the opening range start, disable labels by default, and make labels appear centered by default if shown

This commit is contained in:
moshferatu 2024-02-16 05:39:03 -08:00
parent 01b9601ab9
commit c545af0aad

View File

@ -76,12 +76,12 @@ namespace NinjaTrader.NinjaScript.Indicators
new SimpleFont("Arial", 12);
public static Brush DefaultOpeningRangeFontColor = Brushes.LightGray;
public static bool DefaultShowLabels = true;
public static bool DefaultShowLabels = false;
public static string DefaultOpeningRangeHighLabel = "ORH @ {level}";
public static string DefaultOpeningRangeLowLabel = "ORL @ {level}";
public static string DefaultOpeningRangeMidLabel = "ORM @ {level}";
public static OpeningRangeLabelPosition DefaultOpeningRangeLabelPosition =
OpeningRangeLabelPosition.Above;
OpeningRangeLabelPosition.Center;
private const int PrimaryBars = 0;
private int OpeningRangeBars;
@ -182,7 +182,7 @@ namespace NinjaTrader.NinjaScript.Indicators
}
protected override void OnBarUpdate()
{
{
DateTime now = Times[BarsInProgress][0];
DateTime openingRangeStartTime = GetOpeningRangeStartTime(now);
@ -240,8 +240,10 @@ namespace NinjaTrader.NinjaScript.Indicators
SharpDX.Direct2D1.Brush textBrush = OpeningRangeFontColor.ToDxBrush(RenderTarget);
foreach (OR openingRange in OpeningRanges)
{
int openingRangeStartX = chartControl.GetXByTime(openingRange.StartTime);
{
int barId = ChartBars.GetBarIdxByTime(chartControl, openingRange.StartTime);
DateTime startTime = ChartBars.GetTimeByBarIdx(chartControl, barId);
int openingRangeStartX = chartControl.GetXByTime(startTime);
int openingRangeEndX;
if (openingRange.EndTime == default(DateTime))