NexusFi: Find Your Edge


Home Menu

 





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


Discussion in NinjaTrader

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




 
Search this Thread
  #1 (permalink)
 
podski's Avatar
 podski 
Belgium
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader Brokerage, CQG
Trading: FDAX, FDXM ...maybe
Posts: 357 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?
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
Prediction Markets Lock Fed Pause at 99pct for April 29 …
Prediction Markets & Event Contracts
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
Warsh Confirmed 54-45 on PPI Day -- 97% Say He Holds in …
Prediction Markets & Event Contracts
TradingView Opens Volume Footprint Data to Pine Script - …
TradingView
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
22 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
5 thanks
  #2 (permalink)
 
vvhg's Avatar
 vvhg 
Northern Germany
 
Experience: Intermediate
Platform: NT
Trading: FDAX, CL
Posts: 1,580 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: 357 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,734

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 X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on April 18, 2013


© 2026 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 - Downloads - Top
no new posts