Questions 1: Normally, you see the time & sales in either a green or orange color. I assume when it is green, that means the trade was executed at the Ask price whereas when it is orange, that means the trade was executed at the Bid price. Please confirm that I have this correct.
Question 2: In my custom indicator, how do I determine whether the Last Price was executed at the Bid or Ask price (i.e. whether it was green or orange on the Time & Sales window)? I want to have the ability to count the number of times the volume was greater than 3 when the Last Price was executed at the Bid price compared to the number of times the volume was greater than 3 when the Last Price was executed at the Ask Price. As you can see in below pic, there was a volume of 3 that was executed at the Bid Price and then there was another time where the volume was 4 but it was executed at the Ask Price but they both contributed to my "Count" . I want to count them separately. How do I go about doing that? I attached the code below:
#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.NinjaScript.DrawingTools; #endregion //This namespace holds Indicators in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.Indicators { public class TEST2 : Indicator { private int Count; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "TEST2"; Calculate = Calculate.OnEachTick; IsOverlay = true; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; Count = 0; } else if (State == State.Configure) { } } protected override void OnMarketData(MarketDataEventArgs marketDataUpdate) { if(marketDataUpdate.MarketDataType == MarketDataType.Last) { Print(Time[0].ToString() + string.Format("Last = {0} {1} ", marketDataUpdate.Last, marketDataUpdate.Volume)); if(marketDataUpdate.Volume >= 3) { Count = Count + 1; Print(Time[0].ToString() + "Count = " + Count); } } } protected override void OnBarUpdate() { } #region Properties [NinjaScriptProperty] [Display(ResourceType = typeof(Custom.Resource), Name = "Enter Minute Bar Chart", GroupName = "NinjaScriptStrategyParameters", Order = 3)] public int MinuteBar { get; set; } #endregion } } #region NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private TEST2[] cacheTEST2; public TEST2 TEST2(int minuteBar) { return TEST2(Input, minuteBar); } public TEST2 TEST2(ISeries<double> input, int minuteBar) { if (cacheTEST2 != null) for (int idx = 0; idx < cacheTEST2.Length; idx++) if (cacheTEST2[idx] != null && cacheTEST2[idx].MinuteBar == minuteBar && cacheTEST2[idx].EqualsInput(input)) return cacheTEST2[idx]; return CacheIndicator<TEST2>(new TEST2(){ MinuteBar = minuteBar }, input, ref cacheTEST2); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.TEST2 TEST2(int minuteBar) { return indicator.TEST2(Input, minuteBar); } public Indicators.TEST2 TEST2(ISeries<double> input , int minuteBar) { return indicator.TEST2(input, minuteBar); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.TEST2 TEST2(int minuteBar) { return indicator.TEST2(Input, minuteBar); } public Indicators.TEST2 TEST2(ISeries<double> input , int minuteBar) { return indicator.TEST2(input, minuteBar); } } } #endregion
Comment