Add padding and y-offset configuration properties
This commit is contained in:
parent
f27075712b
commit
f35b0bac63
@ -47,6 +47,9 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
RSIValuesTextColor = Brushes.White;
|
||||
HeaderFont = new SimpleFont("Arial", 12);
|
||||
RSIValuesFont = new SimpleFont("Arial", 12);
|
||||
HorizontalPadding = 20;
|
||||
VerticalPadding = 5;
|
||||
YOffset = 0;
|
||||
}
|
||||
else if (State == State.Configure)
|
||||
{
|
||||
@ -120,7 +123,7 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
using (TextFormat headerTextFormat = HeaderFont.ToDirectWriteTextFormat(),
|
||||
rsiTextFormat = RSIValuesFont.ToDirectWriteTextFormat())
|
||||
{
|
||||
// Calculate maximum header text size
|
||||
// Calculate maximum header text size.
|
||||
foreach (var timeFrame in TimeFrames)
|
||||
{
|
||||
var headerSize = MeasureString(timeFrame, headerTextFormat);
|
||||
@ -128,7 +131,7 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
maxHeaderHeight = Math.Max(maxHeaderHeight, headerSize.Height);
|
||||
}
|
||||
|
||||
// Calculate maximum RSI value text size
|
||||
// Calculate maximum RSI value text size.
|
||||
foreach (var rsiValue in RSIValues)
|
||||
{
|
||||
var rsiText = rsiValue.ToString("F2");
|
||||
@ -138,12 +141,12 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
}
|
||||
}
|
||||
|
||||
maxColWidth += 40; // Adding padding of 40 pixels (20 on each side).
|
||||
int headerHeight = maxHeaderHeight + 10; // Additional padding for header.
|
||||
int rowHeight = maxRowHeight + 10; // Additional padding for rows.
|
||||
maxColWidth += HorizontalPadding * 2;
|
||||
int headerHeight = maxHeaderHeight + (VerticalPadding * 2);
|
||||
int rowHeight = maxRowHeight + (VerticalPadding * 2);
|
||||
|
||||
int x = ChartPanel.W - (maxColWidth * TimeFrames.Length) - 20; // Adjust starting position due to padding.
|
||||
int y = 0;
|
||||
int x = ChartPanel.W - (maxColWidth * TimeFrames.Length) - HorizontalPadding;
|
||||
int y = YOffset;
|
||||
|
||||
// Draw header row.
|
||||
using (TextFormat headerTextFormat = HeaderFont.ToDirectWriteTextFormat())
|
||||
@ -163,7 +166,7 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
}
|
||||
|
||||
// Reset x coordinate for RSI values.
|
||||
x = ChartPanel.W - (maxColWidth * TimeFrames.Length) - 20;
|
||||
x = ChartPanel.W - (maxColWidth * TimeFrames.Length) - HorizontalPadding;
|
||||
y += headerHeight;
|
||||
|
||||
// Draw RSI value row.
|
||||
@ -267,6 +270,21 @@ namespace NinjaTrader.NinjaScript.Indicators
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "RSI Values Font", GroupName = "RSI Dashboard", Order = 12)]
|
||||
public SimpleFont RSIValuesFont { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Range(0, int.MaxValue)]
|
||||
[Display(Name = "Horizontal Padding", GroupName = "RSI Dashboard", Order = 13)]
|
||||
public int HorizontalPadding { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Range(0, int.MaxValue)]
|
||||
[Display(Name = "Vertical Padding", GroupName = "RSI Dashboard", Order = 14)]
|
||||
public int VerticalPadding { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Range(0, int.MaxValue)]
|
||||
[Display(Name = "Y-Offset", GroupName = "RSI Dashboard", Order = 17)]
|
||||
public int YOffset { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -278,18 +296,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, Brush headerTextColor, Brush rSIValuesTextColor, SimpleFont headerFont, SimpleFont rSIValuesFont)
|
||||
public RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor, SimpleFont headerFont, SimpleFont rSIValuesFont, int horizontalPadding, int verticalPadding, int yOffset)
|
||||
{
|
||||
return RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont);
|
||||
return RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont, horizontalPadding, verticalPadding, yOffset);
|
||||
}
|
||||
|
||||
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, SimpleFont headerFont, SimpleFont rSIValuesFont)
|
||||
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, SimpleFont headerFont, SimpleFont rSIValuesFont, int horizontalPadding, int verticalPadding, int yOffset)
|
||||
{
|
||||
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].HeaderTextColor == headerTextColor && cacheRSIDashboard[idx].RSIValuesTextColor == rSIValuesTextColor && cacheRSIDashboard[idx].HeaderFont == headerFont && cacheRSIDashboard[idx].RSIValuesFont == rSIValuesFont && 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].HeaderFont == headerFont && cacheRSIDashboard[idx].RSIValuesFont == rSIValuesFont && cacheRSIDashboard[idx].HorizontalPadding == horizontalPadding && cacheRSIDashboard[idx].VerticalPadding == verticalPadding && cacheRSIDashboard[idx].YOffset == yOffset && 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, HeaderTextColor = headerTextColor, RSIValuesTextColor = rSIValuesTextColor, HeaderFont = headerFont, RSIValuesFont = rSIValuesFont }, 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, HeaderFont = headerFont, RSIValuesFont = rSIValuesFont, HorizontalPadding = horizontalPadding, VerticalPadding = verticalPadding, YOffset = yOffset }, input, ref cacheRSIDashboard);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -298,14 +316,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, Brush headerTextColor, Brush rSIValuesTextColor, SimpleFont headerFont, SimpleFont rSIValuesFont)
|
||||
public Indicators.RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor, SimpleFont headerFont, SimpleFont rSIValuesFont, int horizontalPadding, int verticalPadding, int yOffset)
|
||||
{
|
||||
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont);
|
||||
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont, horizontalPadding, verticalPadding, yOffset);
|
||||
}
|
||||
|
||||
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, SimpleFont headerFont, SimpleFont rSIValuesFont)
|
||||
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, SimpleFont headerFont, SimpleFont rSIValuesFont, int horizontalPadding, int verticalPadding, int yOffset)
|
||||
{
|
||||
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont);
|
||||
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont, horizontalPadding, verticalPadding, yOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,14 +332,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, Brush headerTextColor, Brush rSIValuesTextColor, SimpleFont headerFont, SimpleFont rSIValuesFont)
|
||||
public Indicators.RSIDashboard RSIDashboard(int rSIPeriod, int rSISmoothing, double upperThreshold, double lowerThreshold, Brush aboveThresholdColor, Brush belowThresholdColor, Brush betweenThresholdsColor, Brush headerColor, Brush headerTextColor, Brush rSIValuesTextColor, SimpleFont headerFont, SimpleFont rSIValuesFont, int horizontalPadding, int verticalPadding, int yOffset)
|
||||
{
|
||||
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont);
|
||||
return indicator.RSIDashboard(Input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont, horizontalPadding, verticalPadding, yOffset);
|
||||
}
|
||||
|
||||
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, SimpleFont headerFont, SimpleFont rSIValuesFont)
|
||||
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, SimpleFont headerFont, SimpleFont rSIValuesFont, int horizontalPadding, int verticalPadding, int yOffset)
|
||||
{
|
||||
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont);
|
||||
return indicator.RSIDashboard(input, rSIPeriod, rSISmoothing, upperThreshold, lowerThreshold, aboveThresholdColor, belowThresholdColor, betweenThresholdsColor, headerColor, headerTextColor, rSIValuesTextColor, headerFont, rSIValuesFont, horizontalPadding, verticalPadding, yOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user