Add text color configurations

This commit is contained in:
moshferatu 2023-11-11 06:19:14 -08:00
parent 295fc85a2a
commit e9b5002acb

View File

@ -43,6 +43,8 @@ namespace NinjaTrader.NinjaScript.Indicators
BelowThresholdColor = Brushes.Red;
BetweenThresholdsColor = Brushes.Transparent;
HeaderColor = Brushes.Yellow;
HeaderTextColor = Brushes.Black;
RSIValuesTextColor = Brushes.White;
}
else if (State == State.Configure)
{
@ -136,7 +138,7 @@ namespace NinjaTrader.NinjaScript.Indicators
int textX = x + (maxColWidth - size.Width) / 2; // Center the text horizontally.
int textY = y + (headerHeight - size.Height) / 2; // Center the text vertically.
DrawText(timeFrame, textX, textY, Brushes.Black, textFormat, headerHeight);
DrawText(timeFrame, textX, textY, HeaderTextColor, textFormat, headerHeight);
x += maxColWidth;
}
@ -158,7 +160,7 @@ namespace NinjaTrader.NinjaScript.Indicators
RectangleF rect = new RectangleF(x, y, maxColWidth, rowHeight);
RenderTarget.FillRectangle(rect, bgColor.ToDxBrush(RenderTarget));
DrawText(rsiText, textX, textY, Brushes.White, new TextFormat(Core.Globals.DirectWriteFactory, "Arial", 12), rowHeight);
DrawText(rsiText, textX, textY, RSIValuesTextColor, new TextFormat(Core.Globals.DirectWriteFactory, "Arial", 12), rowHeight);
x += maxColWidth;
}
}
@ -207,23 +209,33 @@ namespace NinjaTrader.NinjaScript.Indicators
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "Above Threshold Color", Order = 5, GroupName = "RSI Dashboard")]
[Display(Name = "Above Threshold", Order = 5, GroupName = "RSI Dashboard")]
public Brush AboveThresholdColor { get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "Below Threshold Color", Order = 6, GroupName = "RSI Dashboard")]
[Display(Name = "Below Threshold", Order = 6, GroupName = "RSI Dashboard")]
public Brush BelowThresholdColor { get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "Between Thresholds Color", Order = 7, GroupName = "RSI Dashboard")]
[Display(Name = "Between Thresholds", Order = 7, GroupName = "RSI Dashboard")]
public Brush BetweenThresholdsColor { get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "Header Color", Order = 8, GroupName = "RSI Dashboard")]
[Display(Name = "Header Row", Order = 8, GroupName = "RSI Dashboard")]
public Brush HeaderColor { get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "Header Text", Order = 9, GroupName = "RSI Dashboard")]
public Brush HeaderTextColor { get; set; }
[NinjaScriptProperty]
[XmlIgnore]
[Display(Name = "RSI Values", Order = 10, GroupName = "RSI Dashboard")]
public Brush RSIValuesTextColor { get; set; }
#endregion
}
}
@ -235,18 +247,18 @@ namespace NinjaTrader.NinjaScript.Indicators
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private RSIDashboard[] cacheRSIDashboard;
public RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor)
public RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor)
{
return RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor);
return RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor);
}
public RSIDashboard RSIDashboard(ISeries<double> input, int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor)
public RSIDashboard RSIDashboard(ISeries<double> input, int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor)
{
if (cacheRSIDashboard != null)
for (int idx = 0; idx < cacheRSIDashboard.Length; idx++)
if (cacheRSIDashboard[idx] != null && cacheRSIDashboard[idx].RSIPeriod == rSIPeriod && cacheRSIDashboard[idx].RSISmoothing == rSISmoothing && cacheRSIDashboard[idx].UpperThreshold == upperThreshold && cacheRSIDashboard[idx].LowerThreshold == lowerThreshold && cacheRSIDashboard[idx].AboveThresholdColor == aboveThresholdColor && cacheRSIDashboard[idx].BelowThresholdColor == belowThresholdColor && cacheRSIDashboard[idx].BetweenThresholdsColor == betweenThresholdsColor && cacheRSIDashboard[idx].HeaderColor == headerColor && cacheRSIDashboard[idx].EqualsInput(input))
if (cacheRSIDashboard[idx] != null && cacheRSIDashboard[idx].RSIPeriod == rSIPeriod && cacheRSIDashboard[idx].RSISmoothing == rSISmoothing && cacheRSIDashboard[idx].UpperThreshold == upperThreshold && cacheRSIDashboard[idx].LowerThreshold == lowerThreshold && cacheRSIDashboard[idx].AboveThresholdColor == aboveThresholdColor && cacheRSIDashboard[idx].BelowThresholdColor == belowThresholdColor && cacheRSIDashboard[idx].BetweenThresholdsColor == betweenThresholdsColor && cacheRSIDashboard[idx].HeaderColor == headerColor && cacheRSIDashboard[idx].HeaderTextColor == headerTextColor && cacheRSIDashboard[idx].RSIValuesTextColor == rSIValuesTextColor && cacheRSIDashboard[idx].EqualsInput(input))
return cacheRSIDashboard[idx];
return CacheIndicator<RSIDashboard>(new RSIDashboard(){ RSIPeriod = rSIPeriod, RSISmoothing = rSISmoothing, UpperThreshold = upperThreshold, LowerThreshold = lowerThreshold, AboveThresholdColor = aboveThresholdColor, BelowThresholdColor = belowThresholdColor, BetweenThresholdsColor = betweenThresholdsColor, HeaderColor = headerColor }, input, ref cacheRSIDashboard);
return CacheIndicator<RSIDashboard>(new RSIDashboard(){ RSIPeriod = rSIPeriod, RSISmoothing = rSISmoothing, UpperThreshold = upperThreshold, LowerThreshold = lowerThreshold, AboveThresholdColor = aboveThresholdColor, BelowThresholdColor = belowThresholdColor, BetweenThresholdsColor = betweenThresholdsColor, HeaderColor = headerColor, HeaderTextColor = headerTextColor, RSIValuesTextColor = rSIValuesTextColor }, input, ref cacheRSIDashboard);
}
}
}
@ -255,14 +267,14 @@ namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor)
public Indicators.RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor)
{
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor);
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor);
}
public Indicators.RSIDashboard RSIDashboard(ISeries<double> input , int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor)
public Indicators.RSIDashboard RSIDashboard(ISeries<double> input , int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor)
{
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor);
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor);
}
}
}
@ -271,14 +283,14 @@ namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor)
public Indicators.RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor)
{
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor);
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor);
}
public Indicators.RSIDashboard RSIDashboard(ISeries<double> input , int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor)
public Indicators.RSIDashboard RSIDashboard(ISeries<double> input , int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor)
{
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor);
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor);
}
}
}