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
User Defined Color for Text
Collapse
X
-
User Defined Color for Text
Hi, I have an indicator that places text on the price chart. Currently, it is set to use ChartControl.Properties.ChartText for setting the color of the text. This is great unless the user wants to use a different color. I have already figured out how to place the text where I want but, I can't yet find how to allow the user to define the color of the text. Continuing on from that, I would also like to give the user the option to decide on the font and font size. Any help would be appreciated.Tags: None
-
Hi memonolog,
Thanks for your reply and for posting the code. Firstly, as I am still new to this forum, can I ask how you posted the code so that it looks like a window within the post and it has scroll bars. I haven't figured out how to do that yet. I also haven't figured out how to quote text from a post. Is there an "idiots guide to forum posting" that I can read?
Secondly, I sort of found where to paste your code for the first part but got a bit lost when it came to the part of:
"in protected override void OnRender(ChartControl chartControl, ChartScale chartScale)"
I don't see that in the code for my indicator. I am still very new to C# so please forgive my ignorance. I have attached the indicator so, if possible, could you please insert your code into my indicator, and that way, I can then see where it should have gone. I want to learn and the best way is to see how the experts do it.Attached Files
-
Hello Kaiviti57,
Great job taking steps to learn C# and NinjaScript!
As far as a brush input, we have an example in the help guide that is right along with what memonolog suggested.
If you are planning to supply this brush to Draw.Text() (the ninja script method), it will not be necessary to implement OnRender() or OnRenderTargetChanged(), this is used for custom rendering. Focus on memonolog's second post.
Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by Kaiviti57 View PostHi memonolog,
Thanks for your reply and for posting the code. Firstly, as I am still new to this forum, can I ask how you posted the code so that it looks like a window within the post and it has scroll bars. I haven't figured out how to do that yet. I also haven't figured out how to quote text from a post. Is there an "idiots guide to forum posting" that I can read?
Secondly, I sort of found where to paste your code for the first part but got a bit lost when it came to the part of:
"in protected override void OnRender(ChartControl chartControl, ChartScale chartScale)"
I don't see that in the code for my indicator. I am still very new to C# so please forgive my ignorance. I have attached the indicator so, if possible, could you please insert your code into my indicator, and that way, I can then see where it should have gone. I want to learn and the best way is to see how the experts do it.
I am new on C# and NinjaScript and I am looking the same as you were looking for:- allow the user to define the color of the text, the font and font size
Thank you
Comment
-
Hello rafo05,
Thanks for your note.
You could find an example of creating a user-defined Brush input in the link shared by my colleague Chelsea in post #3. I am also adding this link below.
Creating a user-defined font style input would not be supported. This is something that would need to be hard-coded into the script when calling the draw method syntax that allows you to specify a SimpleFont argument.
Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)
Something you could consider doing for creating a user-defined font size would be to create a user-defined int variable and then use that variable for the size argument when defining the SimpleFont in your script.
Note that you could create a user-defined input in the Inputs section of the Inputs and Variables screen of the Strategy Builder and click the 'View code' button to see the generated syntax.
See the help guide documentation below for more information and sample code.
Draw.Text: https://ninjatrader.com/support/help.../draw_text.htm
SimpleFont: https://ninjatrader.com/support/help...font_class.htm
Let me know if I may assist further.Brandon H.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_BrandonH View PostHello rafo05,
Thanks for your note.
You could find an example of creating a user-defined Brush input in the link shared by my colleague Chelsea in post #3. I am also adding this link below.
Creating a user-defined font style input would not be supported. This is something that would need to be hard-coded into the script when calling the draw method syntax that allows you to specify a SimpleFont argument.
Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)
Something you could consider doing for creating a user-defined font size would be to create a user-defined int variable and then use that variable for the size argument when defining the SimpleFont in your script.
Note that you could create a user-defined input in the Inputs section of the Inputs and Variables screen of the Strategy Builder and click the 'View code' button to see the generated syntax.
See the help guide documentation below for more information and sample code.
Draw.Text: https://ninjatrader.com/support/help.../draw_text.htm
SimpleFont: https://ninjatrader.com/support/help...font_class.htm
Let me know if I may assist further.
Thank you for your comments. Those gave some hits to solve some problems with my code (I am a newbie on C3 and NinjaScript) but not completely.
I just created a new post asking for help with my code
I am a newbie coding C# and/or NinjaScript. Looking for some other codes and reading some documentation I tried to assemble the code attached but I am not able to get what I aimed for: 1. I want these variables to be accessible to end users to define values as it can be done with other indicators when adding them to a chart
Thank you
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Tim-c, Today, 03:54 AM
|
0 responses
3 views
0 likes
|
Last Post
by Tim-c
Today, 03:54 AM
|
||
Started by FrancisMorro, Today, 03:24 AM
|
0 responses
2 views
0 likes
|
Last Post
by FrancisMorro
Today, 03:24 AM
|
||
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
10 responses
1,771 views
0 likes
|
Last Post
by Leafcutter
Today, 03:01 AM
|
||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, 04-23-2024, 07:51 PM
|
2 responses
31 views
0 likes
|
Last Post
by Max238
Today, 02:25 AM
|
||
Started by Shansen, 08-30-2019, 10:18 PM
|
24 responses
945 views
0 likes
|
Last Post
by spwizard
Today, 01:29 AM
|
Comment