Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

help code

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

    #16
    Hi Edgeliner,

    Thank you for posting.

    Sorry about the new thread issue, we are currently looking into the matter.

    You can use a for loop to test out your condition and if another one has occurred.

    Example:
    Code:
    for( int i = 0; i < 5; i++)
    {
         if(Close[i] > Open[i])
         {
               //do something
               break;
         }
    
         else
         continue;
    }
    This will run a loop to test to see if there was an up bar in the last 5 bars
    if there wasn't an up bar then it will jump to the next iteration in the loop.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #17
      Draw Rectangle/circle

      Hi I want to edit this indicator I want to Draw a rectangle or circle on the main price panel ,Whenever specific high volume occur.
      HTML Code:
      // 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 aa : Indicator
          {
              #region Variables
              // Wizard generated variables
                 private int highVolume = 1000; // Default setting for HighVolume
      		  private int rectWidth	= 0;
      		private Color highAlert = Color.Black;
      		
              // 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()
              {
                 
                 // Add(new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "Volume"));
      			//Add(new Line(Color.DarkGray, 0, "Zero line"));
      			{
                  CalculateOnBarClose	= true;
                  Overlay				= true;
              }
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
                  Value.Set(Volume[0]);
      		
                  if (Volume[0] >= HighVolume)
      			{
      			
      			
      				DrawRectangle("Rectangle", false, rectWidth+ CurrentBar,true, 0, High[0] + 20*TickSize, highAlert, Color.Blue, Color.BlueViolet, 5);
      			}
      			
              }
      
             #region Properties
      		[Description("Enter volume threshold")]
              [Category("Parameters")]
              public int HighVolume
              {
                  get { return highVolume; }
                  set { highVolume = Math.Max(1, value); }
              }
      		
      		/// <summary>
      		/// </summary>
             	
      		[Description("Select Color")]
      		[Category("Colors")]
      		[Gui.Design.DisplayName("highAlert")]
      		public Color HighAlert
      		{
      			get { return highAlert; }
      			set { highAlert = value; }
      		}
      		
      		// Serialize Color object
      		[Browsable(false)]
      		public string highAlertSerialize
      		{
      			get { return NinjaTrader.Gui.Design.SerializableColor.ToString(highAlert); }
      			set { highAlert = NinjaTrader.Gui.Design.SerializableColor.FromString(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 aa[] cacheaa = null;
      
              private static aa checkaa = new aa();
      
              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public aa aa(int highVolume)
              {
                  return aa(Input, highVolume);
              }
      
              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public aa aa(Data.IDataSeries input, int highVolume)
              {
                  if (cacheaa != null)
                      for (int idx = 0; idx < cacheaa.Length; idx++)
                          if (cacheaa[idx].HighVolume == highVolume && cacheaa[idx].EqualsInput(input))
                              return cacheaa[idx];
      
                  lock (checkaa)
                  {
                      checkaa.HighVolume = highVolume;
                      highVolume = checkaa.HighVolume;
      
                      if (cacheaa != null)
                          for (int idx = 0; idx < cacheaa.Length; idx++)
                              if (cacheaa[idx].HighVolume == highVolume && cacheaa[idx].EqualsInput(input))
                                  return cacheaa[idx];
      
                      aa indicator = new aa();
                      indicator.BarsRequired = BarsRequired;
                      indicator.CalculateOnBarClose = CalculateOnBarClose;
      #if NT7
                      indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                      indicator.MaximumBarsLookBack = MaximumBarsLookBack;
      #endif
                      indicator.Input = input;
                      indicator.HighVolume = highVolume;
                      Indicators.Add(indicator);
                      indicator.SetUp();
      
                      aa[] tmp = new aa[cacheaa == null ? 1 : cacheaa.Length + 1];
                      if (cacheaa != null)
                          cacheaa.CopyTo(tmp, 0);
                      tmp[tmp.Length - 1] = indicator;
                      cacheaa = 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.aa aa(int highVolume)
              {
                  return _indicator.aa(Input, highVolume);
              }
      
              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public Indicator.aa aa(Data.IDataSeries input, int highVolume)
              {
                  return _indicator.aa(input, highVolume);
              }
          }
      }
      
      // 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.aa aa(int highVolume)
              {
                  return _indicator.aa(Input, highVolume);
              }
      
              /// <summary>
              /// Enter the description of your new custom indicator here
              /// </summary>
              /// <returns></returns>
              public Indicator.aa aa(Data.IDataSeries input, int highVolume)
              {
                  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.aa(input, highVolume);
              }
          }
      }
      #endregion

      Comment


        #18
        How is it not behaving to your expectations?

        Comment


          #19
          I am a noob don't know how to code .

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          639 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          366 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          107 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          569 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          572 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X