Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninjascript Question for Custom Market Analyzer Column

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

    Ninjascript Question for Custom Market Analyzer Column

    Hi guys,

    I have a custom MA column with 6 data series. I then have 25 or so Forex pairs added to the MA (i.e. each on a different row).

    What I am trying to do, is to reference the name of the instrument/pair in Ninjascript which is for that row. However when I used "Instrument.FullName.ToString()" it is referencing the data series instrument name, not the MA row Instrument name.

    Is anyone able to point me in the right direction to replacing "Instrument.FullName.ToString()" with something that will give me the name of the symbol for that MA row?

    Cheers,
    Shane

    (Below is a sample which is not working):



    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public class PIPtoUSD : MarketAnalyzerColumn
    {
    private double pipsize;
    private double currencyvalue;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Displays the pip movement amount in USD";
    Name = "PIPtoUSD";
    Calculate = Calculate.OnBarClose;
    StandardLot = 100000;
    StopSize = 10;
    AccountBalance = 50000;
    PercentRisk = 1;
    }
    else if (State == State.Configure)
    {
    AddDataSeries("AUDUSD", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("EURUSD", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("GBPUSD", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("NZDUSD", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("USDCAD", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("USDCHF", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("USDJPY", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    }
    }
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    if(Instrument.FullName.ToString() == "EURUSD")
    {
    CurrentText = Instrument.FullName.ToString();
    }
    else
    {
    CurrentText = "";
    }

    }

    #2
    Hello,

    In OnMarketData(), Instrument.FullName (which is already a string) will reflect any instrument which is receiving data, which will include all instruments in the Market Analyzer, as well as your added Data Series. If you are always using different instruments in the Market Analyzer than you are in your script, then you could filter out your added Data Series, and only perform logic on the remaining instruments, which would be those added to the Market Analyzer. The same would be true in reverse, as well, if you wanted to run logic on your added Data Series while ignoring the instruments in the Market Analyzer.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Thanks for your help Dave.

      As per your info I was able to get this working by adding a BarsInProgress filter set to 0.

      Cheers,
      Shane

      Comment

      Latest Posts

      Collapse

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