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!
See more
See less

Partner 728x90

Collapse

Thrust bars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Thrust bars

    Hi Everybody,

    I do try finish thrust bars but I get this error.

    Can somebody explain me what I do wrong , please ?

    Thanks
    Jake

    Code:
            protected override void OnBarUpdate()
    		 {
    			
    			
    			if(CurrentBar < 20) return;
    			Close [0] > (hq=High[0])-(c/2+c);
    		
    	
    			ZOrder=zorder;
    			//Print("zorder: "+zorder);	
    				
                BarCenter.Set(c);
    			BarPivot.Set(p);
    			HighQuarter.Set(hq);
    			LowQuarter.Set(lq);
    Attached Files

    #2
    Hello Jakub,

    Thank you for your post.

    This line -
    Close [0] > (hq=High[0])-(c/2+c);

    This is an incomplete syntax statement.

    Are you trying to do an if check for this?

    What is the goal that you are wanting to achieve?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,
      Original idea is create signal bar with close up/down to (x - %) of bar.
      I have coding for each candle with 25% & 75% points/bar and I need add code for
      "signal bar" which is close[0] higher then 75% or lower then 25% of current bar.
      Between this % value is a "neutral bar".
      I will really appreciate if I u can help me with coding.

      Thanks
      Jake
      Last edited by Jakub; 04-12-2014, 03:27 PM.

      Comment


        #4
        Code:
        #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>
            /// Paints a Cross on the Bar Center and a Dot at the Bar Pivot and the 25% 75% points
            /// </summary>
            [Description("Paints a Cross bsed on the Center of the candle")]
            public class CandleQuarters : Indicator
            {
                #region Variables
            
        		private double c= 0; // center of candle
        		private double p= 0; // pivot of candle
        		private double hq= 0; // High Quarter of candle
        		private double lq= 0; // Low Quarter of Candle
        		private double pm= 0; // Probable Max
        		
        		
        		
        		private int zorder= 30006;
                #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()
                {
                    Add(new Plot(Color.FromKnownColor(KnownColor.Indigo), PlotStyle.Cross, "BarCenter"));
        			Add(new Plot(Color.FromKnownColor(KnownColor.Gold), PlotStyle.Dot, "BarPivot"));
        			Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Dot, "HighQuarter"));
        			Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Dot, "LowQuarter"));
        		
        		
        			Plots[0].Pen.Width = 3;
        			Plots[1].Pen.Width = 1;
        			Plots[2].Pen.Width = 1;
        			Plots[3].Pen.Width = 1;
        			
                    	
        			Overlay				= true;
        			
                }
        
                /// <summary>
              
                /// </summary>
                protected override void OnBarUpdate()
        		 {
        			
        			
        			if(CurrentBar < 20) return;
        			c=(High[0]-Low[0])/2+Low[0];
        			p=(High[0]+Low[0]+Close[0])/3;
        			hq=(High[0]-c)/2+c;
        			lq=c-(High[0]-c)/2;
        			
        	
        			ZOrder=zorder;
        			//Print("zorder: "+zorder);	
        				
                    BarCenter.Set(c);
        			BarPivot.Set(p);
        			HighQuarter.Set(hq);
        			LowQuarter.Set(lq);
        	       
        	}
        
                #region Properties
                [Browsable(false)]	
                [XmlIgnore()]	
                public DataSeries BarCenter
                {
                    get { return Values[0]; }
                }
        		
        		   [Browsable(false)]	
                [XmlIgnore()]	
                public DataSeries BarPivot
                {
                    get { return Values[1]; }
                }
        		
        			   [Browsable(false)]	
                [XmlIgnore()]	
                public DataSeries HighQuarter
                {
                    get { return Values[2]; }
                }
        		
        			   [Browsable(false)]	
                [XmlIgnore()]	
                public DataSeries LowQuarter
                {
                    get { return Values[3]; }
                }
        				
        		/// <summary>
        		/// </summary>
        		[Description("ZOrder")]
        		[GridCategory("Parameters")]
        		public int Zorder
        		{
        			get { return zorder; }
        			set { zorder = value; }
        		}
        			
        
                #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 CandleQuarters[] cacheCandleQuarters = null;
        
                private static CandleQuarters checkCandleQuarters = new CandleQuarters();
        
                /// <summary>
                /// Paints a Cross bsed on the Center of the candle
                /// </summary>
                /// <returns></returns>
                public CandleQuarters CandleQuarters(int zorder)
                {
                    return CandleQuarters(Input, zorder);
                }
        
                /// <summary>
                /// Paints a Cross bsed on the Center of the candle
                /// </summary>
                /// <returns></returns>
                public CandleQuarters CandleQuarters(Data.IDataSeries input, int zorder)
                {
                    if (cacheCandleQuarters != null)
                        for (int idx = 0; idx < cacheCandleQuarters.Length; idx++)
                            if (cacheCandleQuarters[idx].Zorder == zorder && cacheCandleQuarters[idx].EqualsInput(input))
                                return cacheCandleQuarters[idx];
        
                    lock (checkCandleQuarters)
                    {
                        checkCandleQuarters.Zorder = zorder;
                        zorder = checkCandleQuarters.Zorder;
        
                        if (cacheCandleQuarters != null)
                            for (int idx = 0; idx < cacheCandleQuarters.Length; idx++)
                                if (cacheCandleQuarters[idx].Zorder == zorder && cacheCandleQuarters[idx].EqualsInput(input))
                                    return cacheCandleQuarters[idx];
        
                        CandleQuarters indicator = new CandleQuarters();
                        indicator.BarsRequired = BarsRequired;
                        indicator.CalculateOnBarClose = CalculateOnBarClose;
        #if NT7
                        indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                        indicator.MaximumBarsLookBack = MaximumBarsLookBack;
        #endif
                        indicator.Input = input;
                        indicator.Zorder = zorder;
                        Indicators.Add(indicator);
                        indicator.SetUp();
        
                        CandleQuarters[] tmp = new CandleQuarters[cacheCandleQuarters == null ? 1 : cacheCandleQuarters.Length + 1];
                        if (cacheCandleQuarters != null)
                            cacheCandleQuarters.CopyTo(tmp, 0);
                        tmp[tmp.Length - 1] = indicator;
                        cacheCandleQuarters = 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>
                /// Paints a Cross bsed on the Center of the candle
                /// </summary>
                /// <returns></returns>
                [Gui.Design.WizardCondition("Indicator")]
                public Indicator.CandleQuarters CandleQuarters(int zorder)
                {
                    return _indicator.CandleQuarters(Input, zorder);
                }
        
                /// <summary>
                /// Paints a Cross bsed on the Center of the candle
                /// </summary>
                /// <returns></returns>
                public Indicator.CandleQuarters CandleQuarters(Data.IDataSeries input, int zorder)
                {
                    return _indicator.CandleQuarters(input, zorder);
                }
            }
        }
        
        // This namespace holds all strategies and is required. Do not change it.
        namespace NinjaTrader.Strategy
        {
            public partial class Strategy : StrategyBase
            {
                /// <summary>
                /// Paints a Cross bsed on the Center of the candle
                /// </summary>
                /// <returns></returns>
                [Gui.Design.WizardCondition("Indicator")]
                public Indicator.CandleQuarters CandleQuarters(int zorder)
                {
                    return _indicator.CandleQuarters(Input, zorder);
                }
        
                /// <summary>
                /// Paints a Cross bsed on the Center of the candle
                /// </summary>
                /// <returns></returns>
                public Indicator.CandleQuarters CandleQuarters(Data.IDataSeries input, int zorder)
                {
                    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.CandleQuarters(input, zorder);
                }
            }
        }
        #endregion

        Comment


          #5
          Hey Jakub,

          I just wanted to ask if you could clarify what you are trying to accomplish.

          I need add code for "signal bar" which is close[0] higher then 75% or lower then 25% of current bar.Between this % value is a "neutral bar".
          My question is referring to your use of Current Bar.

          is close[0] higher then 75% or lower then 25% of current bar
          When referring to current bar, are you asking to find if the Close[0] is in between 75/25% of the Open/Close/High/Low of the next bar or the previous bar?

          Can you please provide a example of how you are trying to get this value?

          Please let me know if i may be of further assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          12 views
          0 likes
          Last Post DanielSanMartin  
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          11 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          7 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Working...
          X