"emaSeries[0]-ema2Series[0]" it will just print that rather than the value.
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 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:
Code:double subtractedEMAs = emaSeries[0] - ema2Series[0]; DrawText("tag", subtractedEMAs.ToString(), .....);
Zachary G.NinjaTrader Customer Service
-
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:
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 johnMoss, 03-04-2024, 01:53 PM
|
3 responses
46 views
0 likes
|
Last Post
by AndyM
Today, 06:13 PM
|
||
Started by algospoke, Today, 06:01 PM
|
0 responses
8 views
0 likes
|
Last Post
by algospoke
Today, 06:01 PM
|
||
Started by cre8able, Today, 05:53 PM
|
0 responses
8 views
0 likes
|
Last Post
by cre8able
Today, 05:53 PM
|
||
Started by Wessel, 03-23-2024, 02:37 PM
|
3 responses
24 views
0 likes
|
Last Post Today, 04:58 PM | ||
Started by martini, Yesterday, 04:45 PM
|
4 responses
32 views
0 likes
|
Last Post
by martini
Today, 04:48 PM
|
Comment