ES 12-23,2023-09-22 14:59:00,4361.75,4362,4361.5,4362,110
ES 12-23,2023-09-22 14:59:30,4362.25,4362.25,4361,4362.25,421
ES 12-23,2023-09-22 15:00:00,4362.25,4363,4362.25,4362.75,183
ES 12-23,2023-10-03 00:00:30,4318,4318.75,4317.75,4318.75,313
ES 12-23,2023-10-03 00:01:00,4318.5,4320,4318.5,4319.75,720
ES 12-23,2023-10-03 00:01:30,4319.75,4320.25,4319.5,4320,247
ES 12-23,2023-10-03 00:02:00,4320,4320.25,4319.5,4319.5,115
NQ 12-23,2023-09-22 14:58:30,14873.5,14873.75,14872.5,14873,17
NQ 12-23,2023-09-22 14:59:00,14872.5,14874,14872.5,14874,63
NQ 12-23,2023-09-22 14:59:30,14874.75,14875,14871.25,14874.5,120
NQ 12-23,2023-09-22 15:00:00,14874.5,14876.75,14874.5,14876.25,73
NQ 12-23,2023-10-03 00:00:30,14956,14961,14955,14958.75,160
NQ 12-23,2023-10-03 00:01:00,14959,14966.25,14959,14965.25,201
NQ 12-23,2023-10-03 00:01:30,14965.25,14968.5,14964,14966.75,122
NQ 12-23,2023-10-03 00:02:00,14967.25,14967.75,14964,14964.5,60
I am using the following indicator to download these price histories:
[HASHTAG="t3322"]region[/HASHTAG] Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.IO; using System.Linq; using System.Text; using System.Windows.Media; using System.Xml.Serialization; #endregion //This namespace holds Indicators in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Indicators { public class SavePriceHistory : Indicator { private string path; private StreamWriter sw; // a variable for the StreamWriter that will be used protected override void OnStateChange() { if(State == State.SetDefaults) { Calculate = Calculate.OnBarClose; Name = "SavePriceHistory"; PrintTo = PrintTo.OutputTab1; } // Necessary to call in order to clean up resources used by the StreamWriter object else if(State == State.Terminated) { if (sw != null) { sw.Close(); sw.Dispose(); sw = null; } } } protected override void OnBarUpdate() { string path = NinjaTrader.Core.Globals.UserDataDir + Instrument.FullName + ".csv"; // Define the Path to our test file Print(NinjaTrader.Core.Globals.UserDataDir); sw = File.AppendText(path); // Open the path for writing sw.WriteLine(Instrument.FullName + "," + Time[0] + "," + Open[0] + "," + High[0] + "," + Low[0] + "," + Close[0] + "," + VOL()[0]); // Append a new line to the file sw.Close(); // Close the file to allow future calls to access the file again. } } } [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private SavePriceHistory[] cacheSavePriceHistory; public SavePriceHistory SavePriceHistory() { return SavePriceHistory(Input); } public SavePriceHistory SavePriceHistory(ISeries<double> input) { if (cacheSavePriceHistory != null) for (int idx = 0; idx < cacheSavePriceHistory.Length; idx++) if (cacheSavePriceHistory[idx] != null && cacheSavePriceHistory[idx].EqualsInput(input)) return cacheSavePriceHistory[idx]; return CacheIndicator<SavePriceHistory>(new SavePriceHistory(), input, ref cacheSavePriceHistory); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.SavePriceHistory SavePriceHistory() { return indicator.SavePriceHistory(Input); } public Indicators.SavePriceHistory SavePriceHistory(ISeries<double> input ) { return indicator.SavePriceHistory(input); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.SavePriceHistory SavePriceHistory() { return indicator.SavePriceHistory(Input); } public Indicators.SavePriceHistory SavePriceHistory(ISeries<double> input ) { return indicator.SavePriceHistory(input); } } } #endregion
I closed and reopened NinjaTrader and reran the indicator but the same data are still missing.
How can I resolve this problem and access complete price histories?
Comment