You would use DrawText() for this, part of the DrawText() method is specify which bar its tied too.
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
Typical way to draw information from variables on a chart?
Collapse
X
-
One question about DrawText().
Can this be tied to a quadrant on the chart like the DrawTextFixed() can? In looking through all of the inputs for it, it seems like you can position the DrawText() function a certain number of bars back as the x position, and a certain height up as the y position. I can see how this would change depending on the scaling of the charts.
The DrawTextFixed() on the other hand will allow you to simply place your text box in a quadrant, i.e. upper left, lower right etc.
Comment
-
Originally posted by forrestang View PostBrett. If I am wanting to use text that will instead be tied to price bars and not always default to the most recent bar on the charts, what is the common way of accomplishing that?
So that if one where to scroll back in history on a chart, that information would change depending on what the latest bar on the chart was.
Comment
-
I am currently using the DrawTextFixed() to display some information on the chart.
I see there is a way to control the font. Is there an example somewhere of this? As Initially I would just like to make all my text bigger.
Also, I am wondering if there is a way to control all of the variables I have being plotted in the text I have below. As I would like to gain control of the colors of each of the strings I have being outputted. I could draw each one individually I suppose, but I would like to maintain a certain spacing and look on my chart, while being able to keep my text box always in the same location on the chart.
Here is the code I am using for this now along with a picture of it's current output:
Code:string stringToEx1 = "Ex: " +High[1].ToString(); string stringToHi = " Hi: " +High[0].ToString(); string stringToT = " T: " +(High[1]+filter).ToString(); string stringToOp = "Op: " +Open[0].ToString(); string stringToCl = " Cl: " +Close[0].ToString(); string stringToR = " R: " +(High[0]-Low[0]).ToString(); string stringToEx2 = "Ex: " +Low[1].ToString(); string stringToLo = " Lo: " +Low[0].ToString(); string stringToT2 = " T: " +(High[1]-filter).ToString(); //Added this to not disturb original //4 decimal places double temp5 = acclTop[0]; temp5 = Math.Round(temp5, 4); string stringToAcclTop = "AcclTop: " +temp5.ToString(); double temp6 = acclTop[0] - acclBot[0]; temp6 = Math.Round(temp6, 4); string stringToAcclRange = "Accl Band Range: " +temp6.ToString(); double temp7 = acclBot[0]; temp7 = Math.Round(temp7, 4); string stringToAcclBot = "AcclBottom: " +temp7.ToString(); string stringToStopShort = "SL for Short: " +stopTop[0].ToString(); string stringToStopLong = "SL for Long: " +stopBot[0].ToString(); DrawTextFixed("Box1", stringToEx1 + stringToHi + stringToT + "\n" + stringToOp + stringToCl + stringToR + "\n" + stringToEx2 + stringToLo + stringToT2 + "\n" + "\n" + stringToAcclTop + "\n" + stringToAcclRange + "\n" + stringToAcclBot + "\n" + "\n" + stringToStopShort + "\n" + stringToStopLong , TextPosition.TopLeft );
Comment
-
To have a table with consistent look and feel, you will need to use a monospaced font and custom string formatting.
Comment
-
Originally posted by koganam View PostTo have a table with consistent look and feel, you will need to use a monospaced font and custom string formatting.
http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
Comment
-
Originally posted by forrestang View PostSo this can still be done with the DrawTextFixed() method correct? This that you posted is just defined in each string I am using?
The color, however is applied to the function as a whole, and color formatting cannot be applied to individual text in DrawTextFixed().
Comment
-
Originally posted by koganam View PostYes, you can format the text any which way with DrawTextFixed(). The text are strings that obey all the rules of C# formatting.
The color, however is applied to the function as a whole, and color formatting cannot be applied to individual text in DrawTextFixed().
I thought that was what you were saying initially?
Comment
-
If I can't do this, it seems I will need another way of drawing text on a chart, as I want to keep it in a box of some sort so it stay organized and in a certain location on the chart, along with being able to individually color the text based on some conditions each time onBarUpdate() occurs.
Comment
-
Originally posted by forrestang View PostIf I can't do this, it seems I will need another way of drawing text on a chart, as I want to keep it in a box of some sort so it stay organized and in a certain location on the chart, along with being able to individually color the text based on some conditions each time onBarUpdate() occurs.
Comment
-
-
I've switched to using: public override void Plot(), that is residing under my main OnBarUpdate().
And I am getting it to display in exactly the manner I want! But I have a simple question: Can I pass it variables from the main portion of my script?
I don't actually need it to return anything out of it, just to recieve some variables, and display them on the chart.
Can this be done?
Comment
-
Originally posted by forrestang View PostCan I pass it variables from the main portion of my script?
I don't actually need it to return anything out of it, just to recieve some variables, and display them on the chart.
Can this be done?
The variables created in main function declared globally are available to that function.
Also, if you have this in a separate study as I do, and what the study just to draw some text on a chart..... you can first capture into the main body of script variables from OTHER studies, and then those variables are available to the plot() function.
Comment
-
Originally posted by marty087 View PostHi forestang,
Would you be kind enough to share your code for formatting the text as you have?
This is just what I need to do.
Thanks in advance for any help
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by sidlercom80, 10-28-2023, 08:49 AM
|
177 responses
2,400 views
0 likes
|
Last Post
by jeronymite
Today, 06:43 PM
|
||
Started by algospoke, Today, 06:36 PM
|
0 responses
6 views
0 likes
|
Last Post
by algospoke
Today, 06:36 PM
|
||
Started by ETFVoyageur, Yesterday, 06:05 PM
|
8 responses
53 views
0 likes
|
Last Post
by ETFVoyageur
Today, 06:35 PM
|
||
Started by futtrader, 04-21-2024, 01:50 AM
|
7 responses
69 views
0 likes
|
Last Post Today, 06:31 PM | ||
Workspaces
by pibrew
Started by pibrew, Today, 06:10 PM
|
0 responses
13 views
0 likes
|
Last Post
by pibrew
Today, 06:10 PM
|
Comment