Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Help with displaying fixed text
Collapse
X
-
Hello tkaboris,
You need to surround strings with quotes in C#. "tag1".
We highly suggest using external C# learning resources if you plan on doing manual coding as that will greatly help with small hiccups like forgetting quotes around a string.
As a side note you don't need to use RemoveDrawObject if you are updating the text, you just call the method to draw the text again with the same tag. RemoveDrawObject is only used to permanently remove an object so its no longer displayed and is not used when updating an objects text or appearance.
Comment
-
ok. thank you
I dont understand what I do wrong but when in positive it diplays correct text, however when psition is in negative it doenst display correct ammount, nor ammount nor color. I have attached code before. is it something special to display negative number?
Code:protected override void OnMarketData(MarketDataEventArgs marketDataUpdate) { if (marketDataUpdate.MarketDataType == MarketDataType.Last) { #region PNL on the chart NinjaTrader.Gui.Tools.SimpleFont fontNeutral = new NinjaTrader.Gui.Tools.SimpleFont("Verdana", 12) { Size = 20, Bold = true }; NinjaTrader.Gui.Tools.SimpleFont fontPositive = new NinjaTrader.Gui.Tools.SimpleFont("Verdana", 12) { Size = 20, Bold = true }; NinjaTrader.Gui.Tools.SimpleFont fontNegative = new NinjaTrader.Gui.Tools.SimpleFont("Verdana", 12) { Size = 20, Bold = true }; if (Position.MarketPosition != MarketPosition.Flat){ if(Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) >= 0.1){ Draw.TextFixed(this, "tag1", "OPEN PNL $ " + Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]).ToString(), TextPosition.BottomRight, Brushes.RoyalBlue, fontPositive, Brushes.RoyalBlue, Brushes.RoyalBlue, 0); } } else if (Position.MarketPosition != MarketPosition.Flat){ if (Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) <= 0.0){ Draw.TextFixed(this, "tag1", "OPEN PNL $ " + Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]).ToString(), TextPosition.BottomRight, Brushes.Red, fontNegative, Brushes.Red, Brushes.Red, 0); } } else if (Position.MarketPosition == MarketPosition.Flat){ Draw.TextFixed(this, "tag1", "DAILY PNL $ " + Account.Get(AccountItem.GrossRealizedProfitLoss, Currency.UsDollar), TextPosition.BottomRight, Brushes.White, fontNeutral, Brushes.White, Brushes.White, 0); } #endregion }}
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
93 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
138 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
68 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
123 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
73 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment