Firstly, I am a complete novice to NT scripts. I am trying to use the Market Analyzer to monitor some instruments. Of course the current limitation of Market Analyzer is that one can not set up things like cell conditions for columns based on comparing data in multiple columns. A way around this as has been advised by NT support is to create indicators to do the comparisons and then set the cell condition based on the values of the new indicators. On this basis I embarked on attempting to write indicator(s) for what I need.
One of my needs is for the Market Analyzer to check to see if the LastPrice of an instrument is equal to the Upper Band or Lower Band (these are indicators included in another indicator - VWAP, which I have already loaded into NT). So amongst my columns in Market Analyzer is LastPrice, Lower Band, and Upper Band.
To achieve the above, I have tried to write two (I am sure this can be made into just the one indicator, but beyond my capabilities at present) indicators (one for when the Last Price equals Upper Band, and one for when Last Price equals Lower Band), to return value 1 if condition is met, and value 0 otherwise. I then add these new indicators as columns on Market Analyzer, and set the cell condition based on the values 1 or 0.
Below is the code I have written with the help of the indicator wizard and my very limited understanding of C# so far. I have yet to test the code but it compiled successfully. My problem/questions though are:
1. Just for the purpose of coming up with a code, I have used 'Close'. I can't seem to find the synthax for 'LastPrice', if this exist at all. If it does not, what can I use?
2. Logically, is the code Ok i.e. would it do what i want it to?
Many thanks
Dan
// This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { /// <summary> /// Last price equals upper band (MPD+VWAP) /// </summary> [Description("Last price equals upper band (MPD+VWAP)")] public class LPisUB : Indicator { #region Variables // Wizard generated variables // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Overlay = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Set the value Value.Set(Close[0] == VWAP().UpperBand[0] ? 1 : 0); }
Comment