#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 MyCustomIndicator : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "MyCustomIndicator"; Calculate = Calculate.OnBarClose; IsOverlay = false; 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; } else if (State == State.Configure) { } } protected override void OnBarUpdate() { //Add your custom indicator logic here. if(10<CurrentBar) Draw.VerticalLine(this, "tag1", 10, Brushes.Black); } } } #region NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private MyCustomIndicator[] cacheMyCustomIndicator; public MyCustomIndicator MyCustomIndicator() { return MyCustomIndicator(Input); } public MyCustomIndicator MyCustomIndicator(ISeries<double> input) { if (cacheMyCustomIndicator != null) for (int idx = 0; idx < cacheMyCustomIndicator.Length; idx++) if (cacheMyCustomIndicator[idx] != null && cacheMyCustomIndicator[idx].EqualsInput(input)) return cacheMyCustomIndicator[idx]; return CacheIndicator<MyCustomIndicator>(new MyCustomIndicator(), input, ref cacheMyCustomIndicator); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.MyCustomIndicator MyCustomIndicator() { return indicator.MyCustomIndicator(Input); } public Indicators.MyCustomIndicator MyCustomIndicator(ISeries<double> input ) { return indicator.MyCustomIndicator(input); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.MyCustomIndicator MyCustomIndicator() { return indicator.MyCustomIndicator(Input); } public Indicators.MyCustomIndicator MyCustomIndicator(ISeries<double> input ) { return indicator.MyCustomIndicator(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
how to draw a vertical line in subwindows
Collapse
X
-
how to draw a vertical line in subwindows
I want to draw a vertical line in my indicator which is in the subpanel. but the vertical line is only drawn to the main panel. Here is the simplest code to see this
Code:Tags: None
-
Originally posted by alanlopen View PostI want to draw a vertical line in my indicator which is in the subpanel. but the vertical line is only drawn to the main panel.
I have been using this from NinjaTrader_Jim. It seems to work well.
Robotman
Comment
-
Originally posted by NinjaTrader_Jesse View Post
How do I force the region on the subwindow ?
Comment
-
If you set DrawOnPricePanel to false, or if you use the overloads of the draw methods that let you specify it by the individual drawing tool instance and set it to false there, then it will appear on the same subpanel as the indicator plots. What you cannot do is have an indicator in subpanel 2 and put drawing tools in subpanel 3 - it's either in the subpanel the indicator is in or on the price subpanel.
Comment
-
Hello alanlopen,
If you set DrawOnPricePanel = false, and your indicator is in a sub window that will allow its drawing objects to be drawn in that sub window. To make the indicator always use a sub window you can set IsOverlay=false as well.
Make sure that you remove and reapply the indicator after making these changes. If you make changes to SetDefaults and just hit f5 to reload you won't see those changes happen, you physically need to re apply the script for those type of changes.
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
1 view
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
4 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
45 views
0 likes
|
Last Post Today, 12:28 AM | ||
Started by f.saeidi, Today, 12:12 AM
|
0 responses
5 views
0 likes
|
Last Post
by f.saeidi
Today, 12:12 AM
|
||
Started by Conall, Today, 12:06 AM
|
0 responses
9 views
0 likes
|
Last Post
by Conall
Today, 12:06 AM
|
Comment