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 algospoke, Yesterday, 06:40 PM
      2 responses
      19 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Working...
      X