thanks
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
How get the last text on a chart?
Collapse
X
-
How get the last text on a chart?
Hi, i have a indicator that draw on a chart one text when meet conditions. How can get the last text, with the last N bars traded?
thanksTags: None
-
Hello Pbarrionuevo,
Thanks for your post.
Is the indicator that draws the text something you created or have access to its source code?
"How can get the last text, with the last N bars traded?" I'm not sure I understand, can you provide a screenshot the illustrates what you want to accomplish?
Paul H.NinjaTrader Customer Service
-
-
No, i don't have the source code. I use this code to find it, but get an error:
foreach (DrawingTool draw in DrawObjects)
{
if (draw != null) {
if (draw.Tag.Contains("up"))
{
Log ("fond text: " + draw.Tag, LogLevel.Information);
Text texto = draw as DrawingTools.Text; // when do this, i receive this error: Default Strategy 'AlertBullBear': Error on calling 'OnBarUpdate' method on bar 0: Object reference not set to an instance of an object.
// DrawingTools.Text texto = draw as DrawingTools.Text; // and get the same error
Log ("Bars ago: " + texto.Anchor.BarsAgo, LogLevel.Information);
Log ("play the sound", LogLevel.Information);
NinjaTrader.Core.Globals.PlaySound(@"C:\Program Files (x86)\NinjaTrader 8\sounds\CompiledSuccessfully.wav");
}}
}
could it be a different type of object?
Comment
-
Hello Pbarrionuevo,
Thanks for your reply.
Yes, I think it should be DrawingTools.Text texto as in your commented example.
Here is a similar example I have used to read text on the chart, please give this a try:
foreach (DrawingTool draw in DrawObjects.ToList())
{
if (draw is DrawingTools.Text)
{
DrawingTools.Text myText = draw as DrawingTools.Text;
Print("Tag name: "+myText.Tag+" Displayed text: "+myText.DisplayText);
}
}
Note: Print will send the text to the New>Ninjascript output window which is the recommended place to send debugging text. Excessive use of Log() can lead to performance issues.Paul H.NinjaTrader Customer Service
Comment
-
-
Hello Pbarrionuevo,
Thanks for your reply.
You might try checking the DrawObjects.Count and when it changes (meaning you should save it to a variable so you can compare) then perhaps that is your trigger to read.
When you process each (foreach loop) object you can save the anchor time to a variable and the next time through the list skip anything before that time, when the object is a later time then likely that is your candidate to check.
DrawingTools.Text myText = draw as DrawingTools.Text;
Print("Tag name: "+myText.Tag+" Displayed text: "+myText.DisplayText);
Print("startPrice: " + myText.Anchor.Price);
Print("startTime: " + myText.Anchor.Time);Paul H.NinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by frankthearm, Yesterday, 09:08 AM
|
12 responses
43 views
0 likes
|
Last Post Today, 12:05 PM | ||
Started by junkone, Today, 11:37 AM
|
1 response
12 views
0 likes
|
Last Post Today, 11:57 AM | ||
Started by quantismo, 04-17-2024, 05:13 PM
|
5 responses
35 views
0 likes
|
Last Post Today, 11:32 AM | ||
Started by proptrade13, Today, 11:06 AM
|
1 response
6 views
0 likes
|
Last Post Today, 11:27 AM | ||
Started by love2code2trade, 04-17-2024, 01:45 PM
|
4 responses
35 views
0 likes
|
Last Post Yesterday, 10:31 PM |
Comment