Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketAnalyzerColumns latest trade entry price script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MarketAnalyzerColumns latest trade entry price script

    How to modify the built in MarketAnalyzerColumns script below to display the latest trade entry price instead of the last price thanks

    //
    // Copyright (C) 2023, NinjaTrader LLC <www.ninjatrader.com>.
    // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
    //
    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.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    #endregion

    //This namespace holds Market Analyzer columns in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public class LastPrice : MarketAnalyzerColumn
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = NinjaTrader.Custom.Resource.NinjaScriptMarketAnaly zerColumnDescriptionLastPrice;
    Name = NinjaTrader.Custom.Resource.NinjaScriptMarketAnaly zerColumnNameLastPrice;
    IsDataSeriesRequired = false;
    }
    else if (State == State.Realtime)
    {
    if (Instrument != null && Instrument.MarketData != null && Instrument.MarketData.Last != null)
    CurrentValue = Instrument.MarketData.Last.Price;
    }
    }

    protected override void OnMarketData(Data.MarketDataEventArgs marketDataUpdate)
    {
    if (marketDataUpdate.IsReset)
    CurrentValue = double.MinValue;
    else if (marketDataUpdate.MarketDataType == Data.MarketDataType.Last)
    CurrentValue = marketDataUpdate.Price;
    }

    region Miscellaneous
    public override string Format(double value)
    {
    return (value == double.MinValue ? string.Empty : Instrument.MasterInstrument.FormatPrice(value));
    }
    #endregion
    }
    }​

    #2
    Hello Cormick,

    Thanks for your post.

    Please clarify the question below so I may accurately assist.

    When you mention 'latest trade entry price' in your post, do you mean a change in the market depth? For example, the first row of market depth.

    Thanks in advance; I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon sure.
      No I meant latest position entry price.
      For example:
      I entered a 3 contracts trade on the ES at 3904.75 average price 5 minutes ago, the trade is still open.
      I entered a 2 contracts trade on the CL at 68.00 average price 15 minutes ago, the trade is still open.
      I entered a 1 contract trade on the GC at 1912.8 average price 50 minutes ago, the trade is still open.
      How to display 3904.75 for ES, 68.00 for CL and 1912.8 for GC in the MarketAnalyzerColumn (and update for new trades)? Thanks

      Comment


        #4
        Hello Cormick,

        Thanks for that clarification.

        The last price refers to the last market price and I understand that you are wanting to see the account position average price for all open positions.

        You could check out the PositionAvgPrice MarketAnalyzerColumn that comes default with NinjaTrader. The PositionAvgPrice MarketAnalyzerColumn will display the account position average price in the Market Analyzer window.

        For example, if you add the PositionAvgPrice Column to the Market Analyzer window and entered 3 orders on the ES at 3904.75 average price, the value 3904.75 would display in the Market Analyzer.

        Please let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Thanks I'll test asap.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          567 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          548 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X