Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Chart Indicator Text Display Issue
Collapse
X
-
Hello Skatester,
Thank you for your post.
This would be expected. Draw.TextFixed() draws text in one of 5 available pre-defined fixed locations on panel 1 (price panel) of a chart. You have specified all of these Draw.TextFixed() calls to be drawn in the Top Left corner, so they will overlap on top of each other.
This method does not adjust or provide a parameter to adjust where the text will be placed, this object can only be placed in one of the five pre-defined fixed locations.
If you would like more control over where the text is displayed, you can use SharpDX to custom render text on the chart:
Please let us know if you have any further questions.
-
Chart Indicator Text Display Issue
The indicator I created below uses the Draw.TextFixed command for both logic's (SL_TREND and SL_CYCLE_K) to display the proper text on the top left of the chart. Problem is on the chart they display on top of each other instead of left to right in a line, equally spaced. I know that the command line should probably be Draw.Text command with Y offsets but every time I try to code it with a draw.Text command, I get errors.
namespace NinjaTrader.NinjaScript.Indicators
{
public class TPTEST : Indicator
{
private Stochastics stochasticsK;
private SMA sma;
private Brush upBrush;
private Brush downBrush;
private Brush neutralBrush;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"TPTEST";
Name = "TPTEST";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
}
else if (State == State.Configure)
{
stochasticsK = Stochastics(14, 5, 2);
sma = SMA(50);
}
else if (State == State.DataLoaded)
{
upBrush = Brushes.Green;
downBrush = Brushes.Red;
neutralBrush = Brushes.Purple;
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < 1)
return;
double stochasticK = stochasticsK.K[0];
double prevStochasticK = stochasticsK.K[1];
double smaValue = sma[0];
double prevSmaValue = sma[1];
// SL_CYCLE_K Logic
if (stochasticK > prevStochasticK)
{
Draw.TextFixed(this, "stochDirectionK", "%K UP", TextPosition.TopLeft, upBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
}
else if (stochasticK < prevStochasticK)
{
Draw.TextFixed(this, "stochDirectionK", "%K DOWN", TextPosition.TopLeft, downBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
}
// SL_TREND Logic
if (smaValue > prevSmaValue)
{
Draw.TextFixed(this, "smaDirection", "TREND UP", TextPosition.TopLeft, upBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
}
else if (smaValue < prevSmaValue)
{
Draw.TextFixed(this, "smaDirection", "TREND DOWN", TextPosition.TopLeft, downBrush, new SimpleFont("Arial", 15), Brushes.Transparent, Brushes.Transparent, 100);
}
}
}
}
Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by gameuled, Yesterday, 11:18 PM
|
0 responses
12 views
0 likes
|
Last Post
![]()
by gameuled
Yesterday, 11:18 PM
|
||
Started by futurenow, 12-06-2021, 05:49 PM
|
19 responses
989 views
0 likes
|
Last Post
![]()
by Redders
Yesterday, 06:02 AM
|
||
Started by Josephina55, 06-14-2025, 06:30 PM
|
0 responses
29 views
0 likes
|
Last Post
![]()
by Josephina55
06-14-2025, 06:30 PM
|
||
Started by mathfrick2023, 05-08-2025, 12:51 PM
|
8 responses
92 views
0 likes
|
Last Post
![]()
by Yogaman
06-14-2025, 06:01 PM
|
||
Started by several, 04-22-2025, 05:21 AM
|
2 responses
264 views
0 likes
|
Last Post
![]()
by Lukasxgtx
06-13-2025, 06:00 AM
|
Leave a comment: