double prevClose = 0;
double priceChange = 0;
protected override void OnMarketData(Data.MarketDataEventArgs marketDataUpdate)
{
if (marketDataUpdate.IsReset){
CurrentValue = double.MinValue;
return;
}
if (marketDataUpdate.MarketDataType == Data.MarketDataType.Last){
if(marketDataUpdate.Price == null)return;
//if prevClose has not been set yet
if(prevClose == 0)return;
priceChange = Math.Round(marketDataUpdate.Price - prevClose,2);
//This prints the value as expected
Print(priceChange);
//However the value in the column does not display correctly
CurrentValue = priceChange;
return;
}
if (marketDataUpdate.MarketDataType == Data.MarketDataType.LastClose){
if(marketDataUpdate.Price != null){
prevClose = marketDataUpdate.Price;
}
}
}
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
MarketAnalyzer Column returning whole numbers
Collapse
X
-
MarketAnalyzer Column returning whole numbers
I've created a MarketAnalyzer Column that calculates the Current Price - Previous close. It Prints the correct values to the console however, the column shows the values as something entirely different. Here is code and I've also attached the script if you want to test:
Here is a screenshot of the values shown in my window vs. what Prints out:Code:
Last edited by swcooke; 10-04-2019, 08:37 PM.Tags: None
-
Hi Chris,
Sorry for the late reply on this. I have followed your instructions but it still does not output the correct value in the MarketAnalyzer window even though I have made the suggested change. Attached is my simply column. Can you run this and let me know what I am doing wrong? Here it is: npImpact.zip
Comment
-
Hello swcooke,
I was also able to reproduce.
I'm seeing the text is being formatted in Format() override.
You are using 'Core.Globals.FormatQuantity((long) value, false);' to return an int.
Try printing on line 68:
Print(string.Format("priceChange: {0}, FormatQuantity(): {1}", priceChange, Core.Globals.FormatQuantity((long) priceChange, false)));
Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
85 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
124 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
64 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
115 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
67 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment