I'm not sure if I'm approaching this correctly or not and thought it was worth a shot at asking this question here.
My goal is to reference a list or array to pull back timestamps and another string. Both stored as strings currently.
When googling around it seems that the best practice for multiple columns is not using an array but creating a class that will represent a row with two columns. This is where I'm getting that from.
Assuming this is correct (it may not be for Ninja I have no clue) I have this code in the namespace NinjaTrader.NinjaScript.Strategies before the strategy class:
public class tradeTimeStampsClass { public string tradeTimeStamp { get; set; } public string tradeDirection { get; set; } }
List<tradeTimeStampsClass> _trades = new List<tradeTimeStampsClass>(); _trades.Add(new tradeTimeStampsClass {tradeTimeStamp = "1/28/2022 9:01:17", tradeDirection = "S"});
What I'm trying to do is get this new two-column list to play nice with the loop that I had that compared the timestamp in the list to the current time like this:
//loop through the timestamp list foreach(string stamp in _trades) { //parse date if (DateTime.TryParse(stamp, out timeStampParsed)) Print("Parsed successfully: " + timeStampParsed); else Print("Unable to understand DateTime input."); //compare timestamp to time window. if we're in the time window okToTrade = true; if(Time[0] <= timeStampParsed.AddSeconds(10) && Time[0] >= timeStampParsed.AddSeconds(-10)) { Print(Time[0]); Print("WE SHOULD BE GETTING INTO A TRADE HERE"); okToTrade= true; } }
I'm not sure if this is out of the scope of the type of question we can ask on here but I felt like it was worth a shot because I'm spinning my wheels here.
Comment