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
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.
-
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.
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.
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 algospoke, Yesterday, 06:40 PM
|
2 responses
19 views
0 likes
|
Last Post
by algospoke
Today, 07:04 PM
|
||
Started by ghoul, Today, 06:02 PM
|
3 responses
14 views
0 likes
|
Last Post Today, 06:43 PM | ||
Started by jeronymite, 04-12-2024, 04:26 PM
|
3 responses
45 views
0 likes
|
Last Post
by jeronymite
Yesterday, 10:10 PM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
7 responses
20 views
0 likes
|
Last Post Today, 06:16 PM | ||
Started by AttiM, 02-14-2024, 05:20 PM
|
10 responses
181 views
0 likes
|
Last Post
by jeronymite
Today, 06:11 PM
|
Comment