Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Analyzer Column Make Sortable

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

    Market Analyzer Column Make Sortable

    I am creating a EOD Stock Screener in Market Analyzer and have created a MarketAnalyzerColumn that reads a csv data file to get the Stock Sector. It works as expected but will not sort the way other columns sort.

    So, what is the code snippet to make the custom column sortable?

    #2
    Hello TAJTrades,

    How are you setting the value in the column? Are you using CurrentValue?

    There is nothing special that needs to be done for sorting, you can see how the value is being set from the platforms built in columns in the NinjaScript editor. Is your logic working in a similar way to the existing columns?

    What do you see when you sort the column? And to clarify, are you referring to the auto sort or when you click the column header?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I am sorting by clicking on the Column Header.

      I had the code in State.DataLoaded and it prevents the last column from sorting for some reason.
      So I moved the code to State.Configure and it works. Don't know why.

      Column 1: Instrument (NT Script) Sorts when clicking on column header
      Column 2: Description (NT Script) Does not sort when clicking on Column Header
      Column 3: tajSector (My script) Sorts when clicking on Column Header
      Column 4: tajIndustry (My Script) Sorts when clicking on Column Header

      Thanks for confirming "There is nothing special that needs to be done for sorting,". I am going to call it a win and move on.


      For anyone following, I have my own CSV File where I store the data for each stock symbol in the following format:
      Ticker, Corp Name, Exchange, Sector, Industry
      AAPL, Apple Inc, NASDAQ, Computers and Technology, Computer - Mini

      and the simple code:

      // Standard using statements

      using System.IO;

      //This namespace holds MarketAnalyzerColumns in this folder and is required. Do not change it.
      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
      public class tajIndustry : MarketAnalyzerColumn
      {
      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Market Analyzer Column here.";
      Name = "tajIndustry";
      Calculate = Calculate.OnPriceChange;

      IsDataSeriesRequired = false;
      DataType = typeof(string);
      IsEditable = true;
      }
      else if (State == State.Configure)
      {
      string line;
      bool symbolFound = false;
      using (StreamReader sr = new StreamReader(@"C:\Users\TJTra\Documents\NinjaTrade r 8\TAJData\StockSymbolInformation.txt"))
      {
      while((line = sr.ReadLine()) != null)
      {
      string[] item = line.Split(new char[]{','});

      if(item[0].Trim() == Instrument.MasterInstrument.Name.Trim())
      {
      CurrentText = item[4].ToString();
      symbolFound = true;
      break;
      }
      }
      }
      if(!symbolFound)
      CurrentText = "Symbol Not Found";
      }
      }
      }
      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by maybeimnotrader, Yesterday, 05:46 PM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Perr0Grande, Yesterday, 08:16 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by f.saeidi, Yesterday, 08:12 AM
      3 responses
      25 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by algospoke, Yesterday, 06:40 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by quantismo, Yesterday, 05:13 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X