In metatrader there is a special window for this
. I also saw indicators for it https://forex-station.com/attach/file/3420329
Can somebody adapt this to Ninja ? Or is there alreadya script for this ?
#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 PrintBIDASK : Indicator { private Series<double> ExtMapBuffer2; private int tik,t; private double MaxB,MinB=1000; private int period=2000; private int width=50; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "PrintBIDASK"; Calculate = Calculate.OnEachTick; 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; AddPlot(Brushes.Red, "Print_Bid"); AddPlot(Brushes.Lime, "Print_Ask"); AddPlot(Brushes.Ivory, "Print_Median"); } else if (State == State.Configure) { } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ else if(State==State.Historical) { //Make sure our object plots behind the chart bars SetZOrder(-1); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ else if (State == State.DataLoaded)//https://ninjatrader.com/support/helpGuides/nt8/NT%20HelpGuide%20English.html?seriest.htm { ExtMapBuffer2 = new Series<double>(this, MaximumBarsLookBack.Infinite); } } protected override void OnBarUpdate() { //Add your custom indicator logic here. int b; //---- t++; b=period; if(CurrentBar<=1) return; double[]buff=new double[b]; double[]buff2=new double[b]; double[]buff3=new double[b]; double currentAsk = GetCurrentAsk(); double currentBid = GetCurrentBid(); if(tik==0) { for(int i=0; i<b; i++) { buff[i]=currentBid; buff2[i]=currentAsk; buff3[i]=(High[0]+Low[0])/2; } ExtMapBuffer2[0]=currentBid+width*TickSize; ExtMapBuffer2[1]=currentBid-width*TickSize; tik=1; } MaxB=0; MinB=1000; for(int i=b-1; i>0; i--) { buff[i]=buff[i-1]; if(MaxB<buff[i])MaxB=buff[i]; if(MinB>buff[i])MinB=buff[i]; buff2[i]=buff2[i-1]; if(MaxB<buff2[i])MaxB=buff2[i]; if(MinB>buff2[i])MinB=buff2[i]; buff3[i]=buff3[i-1]; if(MaxB<buff3[i])MaxB=buff3[i]; if(MinB>buff3[i])MinB=buff3[i]; } buff[0]=currentBid; buff2[0]=currentAsk; buff3[0]=(High[0]+Low[0])/2; if(CurrentBar<=b) return; for(int i=0; i<b; i++) { Print_Bid[i]=buff[i]; Print_Ask[i]=buff2[i]; Print_Median[i]=buff3[i]; } if((int)(Math.Ceiling(t*0.1)*10)==t) { for(int i=b; i<CurrentBar; i++)//CurrentBar and NOT Bars.Count { // Print(b+" "+i+" "+Bars.Count+" "+CurrentBar+" "+(Count - CurrentBar)); Print_Bid[i]=currentBid; //2000 2000 14402 //2000 2001 14402 //2000 2002 14402 //2000 2003 14402 //2000 2004 14402 //2000 2005 14402 //2000 2006 14402 //2000 2007 14402 //2000 2008 14402 //2000 2009 14402 //2000 2010 14402 //Indicator 'PrintBIDASK': Error on calling 'OnBarUpdate' method on bar 2009: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart. Print_Ask[i]=currentAsk; Print_Median[i]=(High[0]+Low[0])/2; } for (int j = 0; j < CurrentBar; j++) ExtMapBuffer2[j] = currentBid; if(MaxB-currentBid<width*TickSize)ExtMapBuffer2[0]=currentBid+width*TickSize; if(currentBid-MinB<width*TickSize)ExtMapBuffer2[1]=currentBid-width*TickSize; } } #region Properties [Browsable(false)] [XmlIgnore] public Series<double> Print_Bid { get { return Values[0]; } } [Browsable(false)] [XmlIgnore] public Series<double> Print_Ask { get { return Values[1]; } } [Browsable(false)] [XmlIgnore] public Series<double> Print_Median { get { return Values[2]; } } #endregion } } #region NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private PrintBIDASK[] cachePrintBIDASK; public PrintBIDASK PrintBIDASK() { return PrintBIDASK(Input); } public PrintBIDASK PrintBIDASK(ISeries<double> input) { if (cachePrintBIDASK != null) for (int idx = 0; idx < cachePrintBIDASK.Length; idx++) if (cachePrintBIDASK[idx] != null && cachePrintBIDASK[idx].EqualsInput(input)) return cachePrintBIDASK[idx]; return CacheIndicator<PrintBIDASK>(new PrintBIDASK(), input, ref cachePrintBIDASK); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.PrintBIDASK PrintBIDASK() { return indicator.PrintBIDASK(Input); } public Indicators.PrintBIDASK PrintBIDASK(ISeries<double> input ) { return indicator.PrintBIDASK(input); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.PrintBIDASK PrintBIDASK() { return indicator.PrintBIDASK(Input); } public Indicators.PrintBIDASK PrintBIDASK(ISeries<double> input ) { return indicator.PrintBIDASK(input); } } } #endregion
#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 AskBid : Indicator { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "AskBid"; Calculate = Calculate.OnEachTick; 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; AddPlot(Brushes.MediumSeaGreen, "Bid"); AddPlot(Brushes.Orange, "Ask"); } else if (State == State.Configure) { } } protected override void OnBarUpdate() { //Add your custom indicator logic here. Bid[0]=GetCurrentBid(); Ask[0]=GetCurrentAsk(); } [HASHTAG="t3322"]region[/HASHTAG] Properties [Browsable(false)] [XmlIgnore] public Series<double> Bid { get { return Values[0]; } } [Browsable(false)] [XmlIgnore] public Series<double> Ask { get { return Values[1]; } } #endregion } } [HASHTAG="t3322"]region[/HASHTAG] NinjaScript generated code. Neither change nor remove. namespace NinjaTrader.NinjaScript.Indicators { public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase { private AskBid[] cacheAskBid; public AskBid AskBid() { return AskBid(Input); } public AskBid AskBid(ISeries<double> input) { if (cacheAskBid != null) for (int idx = 0; idx < cacheAskBid.Length; idx++) if (cacheAskBid[idx] != null && cacheAskBid[idx].EqualsInput(input)) return cacheAskBid[idx]; return CacheIndicator<AskBid>(new AskBid(), input, ref cacheAskBid); } } } namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns { public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase { public Indicators.AskBid AskBid() { return indicator.AskBid(Input); } public Indicators.AskBid AskBid(ISeries<double> input ) { return indicator.AskBid(input); } } } namespace NinjaTrader.NinjaScript.Strategies { public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase { public Indicators.AskBid AskBid() { return indicator.AskBid(Input); } public Indicators.AskBid AskBid(ISeries<double> input ) { return indicator.AskBid(input); } } } #endregion
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ScottWalsh, Today, 06:52 PM
|
3 responses
19 views
0 likes
|
Last Post Today, 07:30 PM | ||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
1 view
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
||
Started by Haiasi, Today, 06:53 PM
|
1 response
4 views
0 likes
|
Last Post Today, 07:05 PM | ||
Started by ScottW, Today, 06:09 PM
|
1 response
7 views
0 likes
|
Last Post Today, 06:53 PM |
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.
Comment