NexusFi: Find Your Edge


Home Menu

 





Can I use a \n character in an indicator Property ??


Discussion in NinjaTrader

Updated
    1. trending_up 1,447 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Can I use a \n character in an indicator Property ??

  #1 (permalink)
 
podski's Avatar
 podski 
Belgium
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader Brokerage, CQG
Trading: FDAX, FDXM ...maybe
Posts: 388 since Sep 2012
Thanks Given: 499
Thanks Received: 470

Can I have a "\n" character in a string variable that I set using Ninjatrader indicator properties?

Ex:
private string entryText = "Entry\nPrice";

DrawText(..., entryText,...);

+Properties
[GridCategory("Screen Text")]
[Gui.Design.DisplayName ("Entry Price")]
public string EntryText
{
get { return entryText; }
set { entryText = value; }
}

The issue is that if I have a "\n" character and I do not escape it with another \ then it does not appear in the properties. If I escape it then it prints as "Entry\nPrice";

Is there a way around this apart from offsetting with two DrawText statements?

regards

p

Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,583 since Mar 2011
Thanks Given: 1,016
Thanks Received: 2,824


podski View Post
Can I have a "\n" character in a string variable that I set using Ninjatrader indicator properties?

Ex:
private string entryText = "Entry\nPrice";

DrawText(..., entryText,...);

+Properties
[GridCategory("Screen Text")]
[Gui.Design.DisplayName ("Entry Price")]
public string EntryText
{
get { return entryText; }
set { entryText = value; }
}

The issue is that if I have a "\n" character and I do not escape it with another \ then it does not appear in the properties. If I escape it then it prints as "Entry\nPrice";

Is there a way around this apart from offsetting with two DrawText statements?

regards

p

Easiest would be to have two properties and then add the newline in code, then DrawText. Alternatively you could use some character as placeholder for the newline and substitute it for the newline in code.

Vvhg

Hic Rhodos, hic salta.
Reply With Quote
Thanked by:
  #3 (permalink)
 
podski's Avatar
 podski 
Belgium
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader Brokerage, CQG
Trading: FDAX, FDXM ...maybe
Posts: 388 since Sep 2012
Thanks Given: 499
Thanks Received: 470


found it .. thanks vvhg

use the string.Replace() function in the Properties section

[GridCategory("Screen Text")]
[Gui.Design.DisplayName ("Eject Tag")]
public string EjectTag
{
get {
// tmp is a temporary local variable
string tmp = ejectTag.Replace("\\n","\n");
ejectTag = tmp;
return ejectTag;
}
set { ejectTag = value; }
}

Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

This is all good to know and may be useful for other applications. In addition to the Replace method there is a more efficient Stringbuilder class.

C# Replace String Examples

"If we don't loosen up some money, this sucker is going down." -GW Bush, 2008
“Lack of proof that something is true does not prove that it is not true - when you want to believe.” -Humpty Dumpty, 2014
“The greatest shortcoming of the human race is our inability to understand the exponential function.”
Prof. Albert Bartlett
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on April 18, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts