currentHigh = Math.Max(currentHigh, High[0]);
currentLow = Math.Min(currentLow, Low[0]);
if (ShowOpen)
{
if (!PlotCurrentValue || !sameDay)
CurrentOpen.Set(currentOpen);
else
for (int idx = 0; idx < CurrentOpen.Count; idx++)
CurrentOpen.Set(idx, currentOpen);
}
if (ShowHigh)
{
if (!PlotCurrentValue || currentHigh != High[0])
CurrentHigh.Set(currentHigh);
//[B]i think the text should go here but it will not compile[/B]
else
for (int idx = 0; idx < CurrentHigh.Count; idx++)
CurrentHigh.Set(idx, currentHigh);
//DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
[B]DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);[/B]
//[B]it works here but plots at current bar and not the high of current day[/B]
}
if (ShowLow)
{
if (!PlotCurrentValue || currentLow != Low[0])
CurrentLow.Set(currentLow);
else
for (int idx = 0; idx < CurrentLow.Count; idx++)
CurrentLow.Set(idx, currentLow);
}
currentDate = Bars.GetTradingDayFromLocal(Time[0]);
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DrawText on CurrentOHL
Collapse
X
-
DrawText on CurrentOHL
i'm trying to draw some text at the current OHL values. please take a look at the code (bold) and advise. thx!
Code:Tags: None
-
Hello,
When you dont give a drawing object a new name. Instead of drawing a new dot or text. It modifies the current named one already on the chart.
To create a new text object you have to use a new name. A common way to do this is seen below:
DrawText("MyText" + CurrentBar, "Current High", 0, High[0] + 2 * TickSize, Color.Blue);
//it works here but plots at current bar and not the high of current day
Let me know if I can be of further assistance.BrettNinjaTrader Product Management
-
where would the DrawText go?
Hi Brett,
hmmm. i think i made an error. what i was referring to was to DrawText on the "Current Day High" the same way the indicator "CurrentDayOHL" plots lines.
i just wanted to add some text at those levels
hope that clears and thx!
Originally posted by duck_CA View Posti'm trying to draw some text at the current OHL values. please take a look at the code (bold) and advise. thx!
Code:currentHigh = Math.Max(currentHigh, High[0]); currentLow = Math.Min(currentLow, Low[0]); if (ShowOpen) { if (!PlotCurrentValue || !sameDay) CurrentOpen.Set(currentOpen); else for (int idx = 0; idx < CurrentOpen.Count; idx++) CurrentOpen.Set(idx, currentOpen); } if (ShowHigh) { if (!PlotCurrentValue || currentHigh != High[0]) CurrentHigh.Set(currentHigh); //[B]i think the text should go here but it will not compile[/B] else for (int idx = 0; idx < CurrentHigh.Count; idx++) CurrentHigh.Set(idx, currentHigh); //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue); [B]DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);[/B] //[B]it works here but plots at current bar and not the high of current day[/B] } if (ShowLow) { if (!PlotCurrentValue || currentLow != Low[0]) CurrentLow.Set(currentLow); else for (int idx = 0; idx < CurrentLow.Count; idx++) CurrentLow.Set(idx, currentLow); } currentDate = Bars.GetTradingDayFromLocal(Time[0]); }
Comment
-
where would that line of code go?
i got an error when using that to replace where the bold text is in the prior message.
please advise
Originally posted by NinjaTrader_Brett View PostHello,
If I understand you correctly.
In this case I would just add + idx instead of + Current Bar.
Let me know if I can be of further assistance.
Comment
-
Hello,
Need to add curly braces.
for (int idx = 0; idx < CurrentHigh.Count; idx++)
{
CurrentHigh.Set(idx, currentHigh);
//DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);
}
This will DrawText each time Current high changes. You may want to try +idx here. and also + CurrentBar. Most likely you will want +CurrentBar.
I do not know if this is what you want.BrettNinjaTrader Product Management
Comment
-
no luck yet
none of these seem to draw text at the current high of day
Code:if (ShowHigh) { if (!PlotCurrentValue || currentHigh != High[0]) { CurrentHigh.Set(currentHigh); //DrawText("MyText" + idx, "Current High", -12, High[0] + 2 * TickSize, Color.Blue); //DrawText("MyText" + idx, "Current High", 1, High[0] + 2 * TickSize, Color.Blue); DrawText("MyText" +CurrentBar, "Current High", 1, High[0] + 2 * TickSize, Color.Blue); } else for (int idx = 0; idx < CurrentHigh.Count; idx++) { CurrentHigh.Set(idx, currentHigh); //DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue); //DrawText("MyText" +CurrentBar, "Current High", 1, High[0] + 2 * TickSize, Color.Blue); //DrawText("MyText" + idx, "Current High", 1, High[0] + 2 * TickSize, Color.Blue); }
Originally posted by NinjaTrader_Brett View PostHello,
Need to add curly braces.
for (int idx = 0; idx < CurrentHigh.Count; idx++)
{
CurrentHigh.Set(idx, currentHigh);
//DrawDot("MyDot", true, -2, High[0] + 2 * TickSize, Color.Blue);
DrawText("MyText", "Current High", 0, High[0] + 2 * TickSize, Color.Blue);
}
This will DrawText each time Current high changes. You may want to try +idx here. and also + CurrentBar. Most likely you will want +CurrentBar.
I do not know if this is what you want.
Comment
-
Hello,
From a NinjaScript support standpoint I can help you diagnose something if it is not working correctly as you expect. However I cannot create the code for you.
Your suffering here from code logic that does not do what you need. As far as creating the code to do this I unfortuanley cannot do. For this you would need to contact a NinjaScript consultant.
NinjaScript Consultants:
If you have some code that you think should work but is not working you can send the entire code to support at ninjatrader dot com and reference this forum post and put ATTN: brett in the subject line and I can give it a quick run and make a recommendation. However I cannot write the code for you.BrettNinjaTrader Product Management
Comment
-
np...thx for you help!
i understand. have a great wknd!
Originally posted by NinjaTrader_Brett View PostHello,
From a NinjaScript support standpoint I can help you diagnose something if it is not working correctly as you expect. However I cannot create the code for you.
Your suffering here from code logic that does not do what you need. As far as creating the code to do this I unfortuanley cannot do. For this you would need to contact a NinjaScript consultant.
NinjaScript Consultants:
If you have some code that you think should work but is not working you can send the entire code to support at ninjatrader dot com and reference this forum post and put ATTN: brett in the subject line and I can give it a quick run and make a recommendation. However I cannot write the code for you.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment