So, what is the code snippet to make the custom column sortable?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Market Analyzer Column Make Sortable
Collapse
X
-
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? -
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
-
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 Mestor, Today, 03:15 AM
|
0 responses
1 view
0 likes
|
Last Post
by Mestor
Today, 03:15 AM
|
||
Started by Mestor, 03-10-2023, 01:50 AM
|
11 responses
305 views
0 likes
|
Last Post
by z.franck
Today, 02:29 AM
|
||
Started by Padan, Today, 02:02 AM
|
0 responses
6 views
0 likes
|
Last Post
by Padan
Today, 02:02 AM
|
||
Started by bukowa, 11-09-2023, 06:07 PM
|
20 responses
407 views
0 likes
|
Last Post
by Adfra
Today, 01:36 AM
|
||
Started by yertle, Yesterday, 05:49 PM
|
2 responses
11 views
0 likes
|
Last Post
by yertle
Today, 12:12 AM
|
Comment