"emaSeries[0]-ema2Series[0]" it will just print that rather than the value.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DrawText for a calculated value?
Collapse
X
-
DrawText for a calculated value?
Hi, i would like to print a number on the chart just like i do with drawtext() but this number should be calculated, for example the current diffrence between two moving averages. but somehow i cant make it work since drawtext() requires a string so when i use something like
"emaSeries[0]-ema2Series[0]" it will just print that rather than the value.Last edited by BigRo; 10-07-2015, 09:54 AM.Tags: None
-
Hello BigRo,
Thank you for your inquiry.
The reason why it is printing "emaSeries[0]-ema2Series[0]" is because you have wrapped this statement with quotation marks. As DrawText() accepts a string for this parameter, it is just going to output that exact string you have specified.
If you wish to output a value, you will want to create a variable that will hold the value of emaSeries[0] - ema2Series[0] and use that variable with ToString() appended to it.
Example:
Please, let us know if we may be of further assistance.Code:double subtractedEMAs = emaSeries[0] - ema2Series[0]; DrawText("tag", subtractedEMAs.ToString(), .....);Zachary G.NinjaTrader Customer Service
-
Round2TickSize()?Originally posted by BigRo View Postok, worked and is there a way to round this number because it has 10-15 decimals for example
0.0008000000000005 or something.
ref: http://ninjatrader.com/support/helpG...round2ticksize
Comment
-
Originally posted by NinjaTrader_ZacharyG View PostHello BigRo,
Thank you for your inquiry.
The reason why it is printing "emaSeries[0]-ema2Series[0]" is because you have wrapped this statement with quotation marks. As DrawText() accepts a string for this parameter, it is just going to output that exact string you have specified.
If you wish to output a value, you will want to create a variable that will hold the value of emaSeries[0] - ema2Series[0] and use that variable with ToString() appended to it.
Example:
Please, let us know if we may be of further assistance.Code:double subtractedEMAs = emaSeries[0] - ema2Series[0]; DrawText("tag", subtractedEMAs.ToString(), .....);
Dear ZacharyG,
I tried to implement your idea into my Drawtext, but I get an error. Any idea what I am coding wrong?
Comment
-
Hello kadan,
As a heads up, Zachary is no longer with NinjaTrader.
Please expand the Error column so that we may read the full error message.
What is the full line of code causing the error?
From the screenshot it looks like there are too many parameters used in this overload of DrawText(). There are not any overloads that have string, string, bool.
DrawText(string tag, bool autoScale, string text, int barsAgo, double y, int yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)
Perhaps you are wanting the first string to be concatenated?
"EMA 288 max avg. " + countad.ToString()
Chelsea B.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_ChelseaB View PostHello kadan,
As a heads up, Zachary is no longer with NinjaTrader.
Please expand the Error column so that we may read the full error message.
What is the full line of code causing the error?
From the screenshot it looks like there are too many parameters used in this overload of DrawText(). There are not any overloads that have string, string, bool.
DrawText(string tag, bool autoScale, string text, int barsAgo, double y, int yPixelOffset, Color textColor, Font font, StringAlignment alignment, Color outlineColor, Color areaColor, int areaOpacity)
Perhaps you are wanting the first string to be concatenated?
"EMA 288 max avg. " + countad.ToString()
Dear ChelseaB,
Concatenate has helped. Thank you very much for your help :-)
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
561 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
325 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
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment