I'm trying to streamwrite to CSV a List of Times from a chart. I would like to record what time a security had a local maximum. The basic code used to identify the Times & create the List is working fine:
"if (High[5] > Math.Max(MAX(High, 5)[6], MAX(High, 5)[0]))
{
maxtimes.Add(Time[5]);
}"
And the times are all correct. My problems relate to formatting the CSV.
1. My first problem is that Streamwrite is giving a lot of duplicative values, and I still haven't been able to figure out how to delete duplicative values from a CSV in C#!
Any help here would be very much appreciated.
2. My second problem: I would like the file to be saved as: <Instrument name> + "_Maxes" as the CSV filename.
However, when I use this command, it got quite confused / failed to work:
path = @"C:\Users\[blahblahblah]" + Bars.Instrument.MasterInstrument.Name.ToString() + "_Maxes.csv";
That path unfortunately does not seem to work! I get an error message:
"Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
Error on getting/setting property 'PaintPriceMarkers' for NinjaScript '[blah blah]': Exception has been thrown by the target of an invocation."
Furthermore, NT8 zaps this indicator from the list of available indicators on a chart so long as the path is defined to include the instrument name.
Could you please point me in the correct direction here? Thank you!





Comment