I want to Plot my NetLiquidation on a separate panel of my chart. I want it to look like an ATR line that moves up or down depending on my Profit or Loss. My knowledge in C# is very limited but I can manage. Hoping you can give me at least some steps and recommendations. Thank you!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Plot AccountItem.NetLiquidation into chart
Collapse
X
-
Plot AccountItem.NetLiquidation into chart
Hello!
I want to Plot my NetLiquidation on a separate panel of my chart. I want it to look like an ATR line that moves up or down depending on my Profit or Loss. My knowledge in C# is very limited but I can manage. Hoping you can give me at least some steps and recommendations. Thank you!
Tags: None
-
Hello jhudas88,
You could do that by using an indicator and Draw.TextFixed. An indicator will appear in a separate panel if you set its IsOverlay property to false.
There is a sample of finding an account in the following link, that would be needed to store an account to a variable. https://ninjatrader.com/support/help...ount_class.htm
Once you have an account variable you can use the Get method to get values from that account variable. https://ninjatrader.com/support/helpGuides/nt8/get.htm
To draw text on the chart you can use Draw.TextFixed: https://ninjatrader.com/support/help...tsub=textfixed
-
Hello @Jesse!Originally posted by NinjaTrader_Jesse View PostHello jhudas88,
You could do that by using an indicator and Draw.TextFixed. An indicator will appear in a separate panel if you set its IsOverlay property to false.
There is a sample of finding an account in the following link, that would be needed to store an account to a variable. https://ninjatrader.com/support/help...ount_class.htm
Once you have an account variable you can use the Get method to get values from that account variable. https://ninjatrader.com/support/helpGuides/nt8/get.htm
To draw text on the chart you can use Draw.TextFixed: https://ninjatrader.com/support/help...tsub=textfixed
1. I was able to get My variables and named it private double Netliquidation
2. I am trying to plot it to the chart, but it doesn't show up.
Instead of Draw.TextFixed I want it to be an AddPlot(Brushes.Blue, "NetLiquidation")
but it does not plot a line on my chart. This indicator aims to Plot my NetLiquidation in Currency on another chart panel, and then I am planning to eventually Plot another Line with a certain drawdown Limit value to help me monitor my Open PNL drawdowns live on the same chart but on a different panel.
Comment
-
Code:#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds Indicators in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Indicators { public class TrailingDrawdown : Indicator { private Account account; private Position position; private double realizedPnL; private double unRealizedPnL; private double NetLiquidation; private double highestNetLiqVal; private double drawdown; private double MaxDrawdown; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "TrailingDrawdown"; Calculate = Calculate.OnEachTick; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; } else if (State == State.Configure) { } else if (State == State.DataLoaded) { // Find our account lock (Account.All) account = Account.All.FirstOrDefault(a => a.Name == AccountName); // Subscribe to account item updates if (account != null) { account.AccountItemUpdate += OnAccountItemUpdate; account.PositionUpdate += OnPositionUpdate; foreach (Position pos in account.Positions) if (pos.Instrument == Instrument) position = pos; realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar); NetLiquidation = account.Get(AccountItem.NetLiquidation, Currency.UsDollar); } } else if (State == State.Terminated) { // Make sure to unsubscribe to the account item subscription if (account != null) { account.AccountItemUpdate -= OnAccountItemUpdate; account.PositionUpdate -= OnPositionUpdate; } } } private void OnAccountItemUpdate(object sender, AccountItemEventArgs e) { drawdown = highestNetLiqVal - NetLiquidation; if (e.AccountItem == AccountItem.RealizedProfitLoss) realizedPnL = e.Value; if (e.AccountItem == AccountItem.NetLiquidation) NetLiquidation = e.Value; if (NetLiquidation != null && NetLiquidation > highestNetLiqVal) highestNetLiqVal = NetLiquidation; if (drawdown != null && drawdown > MaxDrawdown) MaxDrawdown = drawdown; } private void OnPositionUpdate(object sender, PositionEventArgs e) { if (e.Position.Instrument == Instrument && e.MarketPosition == MarketPosition.Flat) position = null; else if (e.Position.Instrument == Instrument && e.MarketPosition != MarketPosition.Flat) position = e.Position; } protected override void OnBarUpdate() { // Plot the private double variable on the chart using DrawText if (State == State.SetDefaults) { IsOverlay = false; AddPlot(Brushes.Orange, "NetLiquidation"); } } [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))] public string AccountName { get; set; } public SimpleFont Font { get; set; } public PerformanceUnit PerformanceUnit { get; set; } } } #region NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private TrailingDrawdown[] cacheTrailingDrawdown; public TrailingDrawdown TrailingDrawdown() { return TrailingDrawdown(Input); } public TrailingDrawdown TrailingDrawdown(ISeries<double> input) { if (cacheTrailingDrawdown != null) for (int idx = 0; idx < cacheTrailingDrawdown.Length; idx++) if (cacheTrailingDrawdown[idx] != null && cacheTrailingDrawdown[idx].EqualsInput(input)) return cacheTrailingDrawdown[idx]; return CacheIndicator<TrailingDrawdown>(new TrailingDrawdown(), input, ref cacheTrailingDrawdown); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.TrailingDrawdown TrailingDrawdown() { return indicator.TrailingDrawdown(Input); } public Indicators.TrailingDrawdown TrailingDrawdown(ISeries<double> input ) { return indicator.TrailingDrawdown(input); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.TrailingDrawdown TrailingDrawdown() { return indicator.TrailingDrawdown(Input); } public Indicators.TrailingDrawdown TrailingDrawdown(ISeries<double> input ) { return indicator.TrailingDrawdown(input); } } } #endregion
Comment
-
Hello jhudas88,
Please see the following page which shows how to add plots and also set them, you need to fix the code you have in OnBarUpdate. https://ninjatrader.com/support/help...ghtsub=addplot
After moving the AddPlot to the correct location you would need to move the account.Get into OnBarUpdate to get a value and then plot it for each bar. The following code would go in OnBarUpdate:
Code:protected override void OnBarUpdate() { if (account != null) { realizedPnL = account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar); NetLiquidation = account.Get(AccountItem.NetLiquidation, Currency.UsDollar); //set plots to the values you wanted } }
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 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
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
574 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment