#region Using declarations using System; using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { /// <summary> /// Enter the description of your new custom indicator here /// </summary> [Description("Enter the description of your new custom indicator here")] public class RangeBarsSinceSession : Indicator { #region Variables int barcount = 1; #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 = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (BarsArray[0].FirstBarOfSession) { barcount = 1; } double price; if (barcount % 2 == 0) { price = High[0] + TickSize * 2; } else {price = Low[0] - TickSize * 2;} base.DrawText("txt" + CurrentBar,(Range()[0]/TickSize).ToString(),0,price,Color.Black); barcount += 1; } #region Properties #endregion } } #region NinjaScript generated code. Neither change nor remove. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { public partial class Indicator : IndicatorBase { private RangeBarsSinceSession[] cacheRangeBarsSinceSession = null; private static RangeBarsSinceSession checkRangeBarsSinceSession = new RangeBarsSinceSession(); /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public RangeBarsSinceSession RangeBarsSinceSession() { return RangeBarsSinceSession(Input); } /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public RangeBarsSinceSession RangeBarsSinceSession(Data.IDataSeries input) { if (cacheRangeBarsSinceSession != null) for (int idx = 0; idx < cacheRangeBarsSinceSession.Length; idx++) if (cacheRangeBarsSinceSession[idx].EqualsInput(input)) return cacheRangeBarsSinceSession[idx]; lock (checkRangeBarsSinceSession) { if (cacheRangeBarsSinceSession != null) for (int idx = 0; idx < cacheRangeBarsSinceSession.Length; idx++) if (cacheRangeBarsSinceSession[idx].EqualsInput(input)) return cacheRangeBarsSinceSession[idx]; RangeBarsSinceSession indicator = new RangeBarsSinceSession(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; Indicators.Add(indicator); indicator.SetUp(); RangeBarsSinceSession[] tmp = new RangeBarsSinceSession[cacheRangeBarsSinceSession == null ? 1 : cacheRangeBarsSinceSession.Length + 1]; if (cacheRangeBarsSinceSession != null) cacheRangeBarsSinceSession.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheRangeBarsSinceSession = tmp; return indicator; } } } } // This namespace holds all market analyzer column definitions and is required. Do not change it. namespace NinjaTrader.MarketAnalyzer { public partial class Column : ColumnBase { /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.RangeBarsSinceSession RangeBarsSinceSession() { return _indicator.RangeBarsSinceSession(Input); } /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public Indicator.RangeBarsSinceSession RangeBarsSinceSession(Data.IDataSeries input) { return _indicator.RangeBarsSinceSession(input); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.RangeBarsSinceSession RangeBarsSinceSession() { return _indicator.RangeBarsSinceSession(Input); } /// <summary> /// Enter the description of your new custom indicator here /// </summary> /// <returns></returns> public Indicator.RangeBarsSinceSession RangeBarsSinceSession(Data.IDataSeries input) { if (InInitialize && input == null) throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method"); return _indicator.RangeBarsSinceSession(input); } } } #endregion
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
RangeBarSinceSession
Collapse
X
-
RangeBarSinceSession
Please check this pic ,I want to see Points instead of ticks which is 20 ticks= 1 point also want data to be 1 digit after decimal
HTML Code:Tags: None
-
Hello SLASH,
Thank you for your note.
You would need to format the value before drawing it on the chart. Such as using Math.Round: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ScottW, Today, 06:09 PM
|
1 response
4 views
0 likes
|
Last Post Today, 06:53 PM | ||
Started by ScottWalsh, Today, 06:52 PM
|
0 responses
4 views
0 likes
|
Last Post
by ScottWalsh
Today, 06:52 PM
|
||
Started by ftsc2022, 10-25-2022, 12:03 PM
|
5 responses
256 views
0 likes
|
Last Post Today, 06:48 PM | ||
Started by Board game geek, 10-29-2023, 12:00 PM
|
14 responses
244 views
0 likes
|
Last Post
by DJ888
Today, 05:38 PM
|
||
Started by Waxavi, 04-19-2024, 02:10 AM
|
4 responses
56 views
0 likes
|
Last Post
by sonia0101
Today, 04:02 PM
|
Comment