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

Change Instrument Data Series

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

    Change Instrument Data Series

    Hello,

    I am wondering if it is possible to apply an indicator that is calculating based on a 3 minute time frame, and apply it to a tick chart. I can't quite get it to work out. Any help is appreciated. thanks:
    Code:
    #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 StochCross : Indicator
    {
            private Stochastics Stochastics1;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
    
                    Description                                    = "StochCross";
                    Name                                        = "StochCross";
                    Calculate                                    = Calculate.OnEachTick;
                    IsOverlay                                    = 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)
                {                
                    Stochastics1                = Stochastics(9, 12, 1);
                AddDataSeries(BarsPeriodType.Minute, 3);
    
                }
            }
    
            protected override void OnBarUpdate()
            {
    
    
                if (CurrentBars[0] < 1)
                return;
    
                 // Set
                if ((CrossAbove(Stochastics1.K, Stochastics1.D, 1))  && (Stochastics1.K[0] < 50) && (Close[0] > EMA(50)[0]))
                {
                    Draw.ArrowUp(this,  CurrentBar.ToString(), true, 0, Low[0]-3, Brushes.Lime);
                }
            }
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private StochCross[] cacheStochCross;
            public StochCross StochCross()
            {
                return StochCross(Input);
            }
    
            public StochCross StochCross(ISeries<double> input)
            {
                if (cacheStochCross != null)
                    for (int idx = 0; idx < cacheStochCross.Length; idx++)
                        if (cacheStochCross[idx] != null &&  cacheStochCross[idx].EqualsInput(input))
                            return cacheStochCross[idx];
                return CacheIndicator<StochCross>(new StochCross(), input, ref cacheStochCross);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.StochCross StochCross()
            {
                return indicator.StochCross(Input);
            }
    
            public Indicators.StochCross StochCross(ISeries<double> input )
            {
                return indicator.StochCross(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.StochCross StochCross()
            {
                return indicator.StochCross(Input);
            }
    
            public Indicators.StochCross StochCross(ISeries<double> input )
            {
                return indicator.StochCross(input);
            }
        }
    }
    
    #endregion

    #2
    Hello lenmat,

    Thanks for your post.

    While you have added the 3 minute data series, the stochastics is assigned to the default data series (chart bars): Stochastics1 = Stochastics(9, 12, 1);
    You need to assign the Stochastics to the added data series by adding the data series into the parameters of the stochastics, for example, Stochastics1 = Stochastics( Closes[1], 9, 12, 1); Reference: https://ninjatrader.com/support/help...us/?closes.htm

    If you are unfamiliar with the use of Closes[barsArray], please read the entire section here: https://ninjatrader.com/support/help...nstruments.htm as there are a number of concepts to ensure you cover with your code. For example, you are only checking for CurrentBars[0] < 1 and need to add a check for CurrentBars[1] as well.

    Also, I would recommend that you add a BarsInProgress == 0 check as your OnBarUpdate will be triggered by both the chart's bars and the added 3 minute bars as each tick occurs and when this happens the references change (specifically Low[0] , Close[0] and EMA(50)[0] would then point to the 3 minute bars). Also, there is no need for your code to run when the 3-minute bars tick occurs and this will make your code less efficient.

    In the Draw.ArrowUp() code you have Low[0] - 3 and likely this will not work, I suspect you need: Low[0] - 3 * TickSize to place the arrow 3 ticks below the low of the bar.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul, thank you for the reply. I do not want anything to calculate off the tick chart at all, only calculate from the 3 minute series, and just display the arrow on the tick chart.Added BarsInProgress == 01 because of this based on what I found here:



      I did some updates, but what I couldn't find in the link was how to define the Closes pieces with the time series. Settings lots of errors as I am sure you will see. Also, do I need a Closes[1] to get the Close[0] for my cross. Here is where I am sitting. Thanks again, new to coding, still learning.

      Code:
      #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 StochCrossUpTick : Indicator
      {
              private Stochastics Stochastics1;
      
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
      
                      Description                                    = "StochCross";
                      Name                                        = "StochCrossUpTick";
                      Calculate                                    = Calculate.OnEachTick;
      
                  }
                  else if (State == State.Configure)
                  {                
      
                  AddDataSeries(BarsPeriodType.Minute, 3);
      
                  }
              }
      
              protected override void OnBarUpdate()
              {
      
      
                  if (BarsInProgress == 1)
                  return;
      
                  Closes[1] = BarsPeriodType.Minute, 3;
                  Stochastics1                = Stochastics(Closes[1],9, 12, 1);
      
                   // Set
                  if ((CrossAbove(Stochastics1.K, Stochastics1.D, 1))  && ((Closes[1]Close[0]) > EMA(Closes[1],50)[0]))
                  {
                      Draw.ArrowUp(this,  CurrentBar.ToString(), true, 0, Low[0]-3, Brushes.Lime);
                  }
              }
          }
      }
      
      #region NinjaScript generated code. Neither change nor remove.
      
      namespace NinjaTrader.NinjaScript.Indicators
      {
          public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
          {
              private StochCrossUpTick[] cacheStochCrossUpTick;
              public StochCrossUpTick StochCrossUpTick()
              {
                  return StochCrossUpTick(Input);
              }
      
              public StochCrossUpTick StochCrossUpTick(ISeries<double> input)
              {
                  if (cacheStochCrossUpTick != null)
                      for (int idx = 0; idx < cacheStochCrossUpTick.Length; idx++)
                          if (cacheStochCrossUpTick[idx] != null &&  cacheStochCrossUpTick[idx].EqualsInput(input))
                              return cacheStochCrossUpTick[idx];
                  return CacheIndicator<StochCrossUpTick>(new StochCrossUpTick(), input, ref cacheStochCrossUpTick);
              }
          }
      }
      
      namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
      {
          public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
          {
              public Indicators.StochCrossUpTick StochCrossUpTick()
              {
                  return indicator.StochCrossUpTick(Input);
              }
      
              public Indicators.StochCrossUpTick StochCrossUpTick(ISeries<double> input )
              {
                  return indicator.StochCrossUpTick(input);
              }
          }
      }
      
      namespace NinjaTrader.NinjaScript.Strategies
      {
          public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
          {
              public Indicators.StochCrossUpTick StochCrossUpTick()
              {
                  return indicator.StochCrossUpTick(Input);
              }
      
              public Indicators.StochCrossUpTick StochCrossUpTick(ISeries<double> input )
              {
                  return indicator.StochCrossUpTick(input);
              }
          }
      }
      
      #endregion

      Comment


        #4
        Hello lenmat,

        Thanks for your reply.

        While I know it may seem counter-intuitive, I recommend that you change to BarsInProgress == 0 because when drawing on the chart, you need drawing objects placed relative to the chart bars.

        This line: Closes[1] = BarsPeriodType.Minute, 3; is not needed, please remove it.

        This line: Stochastics1 = Stochastics(Closes[1],9, 12, 1); now correctly references the 3 minute data however it needs to be put back into State.Configure, please move it back there and remove it from the OnBarUpodate() section.

        Lastly, please change the Low[0]-3 to Low[0] -3 *TickSize

        With the changes listed above, it will compile without errors and will display the arrows three ticks below the chart bar when the 3 min stochastic crosses.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi Paul, thank you for the reply, I simplified even more, and it is compiling, however nothing shows up on the tick chart. When I apply the indicator to the 3 minute, I do get the arrow ups. Any thoughts? Should I be specifically calling out the instrument, even though they are the same?

          Code:
          #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 StochCrossUpTick : Indicator
          {
                  private Stochastics Stochastics1;
                 private EMA EMA1;
          
                  protected override void OnStateChange()
                  {
                      if (State == State.SetDefaults)
                      {
          
                          Description                                    = "StochCross";
                          Name                                        = "StochCrossUpTick";
                          Calculate                                    = Calculate.OnEachTick;
          
                      }
                      else if (State == State.Configure)
                      {                
          
                      AddDataSeries(BarsPeriodType.Minute, 3);
                          Stochastics1                = Stochastics(Closes[1],9, 12, 1);
          
                      }
                  }
          
                  protected override void OnBarUpdate()
                  {
          
          
                      if (BarsInProgress == 0)
                      return;
          
          
                      if ((CrossAbove(Stochastics1.K, Stochastics1.D, 1)))
                      {
                          Draw.ArrowUp(this,  CurrentBar.ToString(), true, 0, Low[0]-10*TickSize, Brushes.Lime);
                      }
                  }
              }
          }
          
          #region NinjaScript generated code. Neither change nor remove.
          
          namespace NinjaTrader.NinjaScript.Indicators
          {
              public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
              {
                  private StochCrossUpTick[] cacheStochCrossUpTick;
                  public StochCrossUpTick StochCrossUpTick()
                  {
                      return StochCrossUpTick(Input);
                  }
          
                  public StochCrossUpTick StochCrossUpTick(ISeries<double> input)
                  {
                      if (cacheStochCrossUpTick != null)
                          for (int idx = 0; idx < cacheStochCrossUpTick.Length; idx++)
                              if (cacheStochCrossUpTick[idx] != null &&  cacheStochCrossUpTick[idx].EqualsInput(input))
                                  return cacheStochCrossUpTick[idx];
                      return CacheIndicator<StochCrossUpTick>(new StochCrossUpTick(), input, ref cacheStochCrossUpTick);
                  }
              }
          }
          
          namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
          {
              public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
              {
                  public Indicators.StochCrossUpTick StochCrossUpTick()
                  {
                      return indicator.StochCrossUpTick(Input);
                  }
          
                  public Indicators.StochCrossUpTick StochCrossUpTick(ISeries<double> input )
                  {
                      return indicator.StochCrossUpTick(input);
                  }
              }
          }
          
          namespace NinjaTrader.NinjaScript.Strategies
          {
              public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
              {
                  public Indicators.StochCrossUpTick StochCrossUpTick()
                  {
                      return indicator.StochCrossUpTick(Input);
                  }
          
                  public Indicators.StochCrossUpTick StochCrossUpTick(ISeries<double> input )
                  {
                      return indicator.StochCrossUpTick(input);
                  }
              }
          }
          
          #endregion

          Comment


            #6
            Hello lenmat,

            Thanks for your reply.

            It may be that there is a "run time" error occurring when applying the indicator to the chart. It is always a good idea to check the "log" tab of the control center for any related error messages when the script is not performing as expected.

            In looking at your code now I see that you are not checking to see that a certain amount of bars for each data series has been loaded and it may be that you have a log error about accessing a bar that does not exist.

            As a suggestion please add: if (CurrentBars[0] < 10 || CurrentBars[1] < 10) return; as the first line of code in the OnBarUpdate() section. This line of code is checking to see if both the chart bars and the added data series first 10 bars have been processed before allowing the code below that line to process. For further detail on CurrentBars[], please see: https://ninjatrader.com/support/help...urrentbars.htm
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thank, you. I did not know about the log. I still do not believe this is pulling in the 3 minute data series. When I put on the 3 minute chart, it matches a different indicator I already had on the 3 minute, but on the tick chart, it is completely off. When I remove the "Closes[1] from the Stochastics1 definition area, the arrows are in the same place. Any thoughts?

              Code:
              #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 StochCrossUpTick : Indicator
              {
                      private Stochastics Stochastics1;
              
              
              
              
                      protected override void OnStateChange()
                      {
                          if (State == State.SetDefaults)
                          {
              
                              Description                                    = "StochCross";
                              Name                                        = "StochCrossUpTick";
                              Calculate                                    = Calculate.OnEachTick;
              
                          }
                          else if (State == State.Configure)
                          {                
              
                              AddDataSeries(BarsPeriodType.Minute, 3);
                              Stochastics1 = Stochastics(Closes[1],9, 12, 1);
              
              
              
                          }
                      }
              
                      protected override void OnBarUpdate()
                      {
                          if (CurrentBars[0] < 10 || CurrentBars[1] < 10) return;
              
                          if (BarsInProgress == 0)
                          return;
              
              
                          if ((CrossAbove(Stochastics1.K, Stochastics1.D, 1)))
                          {
                              Draw.ArrowUp(this,  CurrentBar.ToString(), true, 0, Low[0]-5*TickSize, Brushes.Orange);
                          }
                      }
                  }
              }
              
              #region NinjaScript generated code. Neither change nor remove.
              
              namespace NinjaTrader.NinjaScript.Indicators
              {
                  public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                  {
                      private StochCrossUpTick[] cacheStochCrossUpTick;
                      public StochCrossUpTick StochCrossUpTick()
                      {
                          return StochCrossUpTick(Input);
                      }
              
                      public StochCrossUpTick StochCrossUpTick(ISeries<double> input)
                      {
                          if (cacheStochCrossUpTick != null)
                              for (int idx = 0; idx < cacheStochCrossUpTick.Length; idx++)
                                  if (cacheStochCrossUpTick[idx] != null &&  cacheStochCrossUpTick[idx].EqualsInput(input))
                                      return cacheStochCrossUpTick[idx];
                          return CacheIndicator<StochCrossUpTick>(new StochCrossUpTick(), input, ref cacheStochCrossUpTick);
                      }
                  }
              }
              
              namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
              {
                  public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                  {
                      public Indicators.StochCrossUpTick StochCrossUpTick()
                      {
                          return indicator.StochCrossUpTick(Input);
                      }
              
                      public Indicators.StochCrossUpTick StochCrossUpTick(ISeries<double> input )
                      {
                          return indicator.StochCrossUpTick(input);
                      }
                  }
              }
              
              namespace NinjaTrader.NinjaScript.Strategies
              {
                  public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                  {
                      public Indicators.StochCrossUpTick StochCrossUpTick()
                      {
                          return indicator.StochCrossUpTick(Input);
                      }
              
                      public Indicators.StochCrossUpTick StochCrossUpTick(ISeries<double> input )
                      {
                          return indicator.StochCrossUpTick(input);
                      }
                  }
              }
              
              #endregion

              Comment


                #8
                I think I just got it figured out. I moved
                Stochastics1 = Stochastics(Closes[1],9, 12, 1); Under bar update and it appears to be working. Thanks for your help today!

                Comment


                  #9
                  The logic is working, it is posting an arrow on my tick chart, when calculating from the 3 Minute. However I notice the Arrow will slide along each tick bar, until the 3 minute bar closes. Is there a way to get the arrow to stay on the tick it occurred on, and create another arrow if the condition happens again in the 3 minute bar?

                  Code:
                  #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 CylceLowArrow : Indicator
                  
                  {
                  
                          private Stochastics Stochastics1;
                  
                      private EMA EMA1;
                  
                  
                  
                  
                  
                  
                  
                          protected override void OnStateChange()
                  
                          {
                  
                              if (State == State.SetDefaults)
                  
                              {
                  
                  
                  
                                  Description                                    = "Buy Signal to be put on the tick chart";
                  
                                  Name                                        = "CycleLowArrow";
                  
                                  Calculate                                    = Calculate.OnEachTick;
                  
                  
                  
                              }
                  
                              else if (State == State.Configure)
                  
                              {                
                  
                  
                  
                                  AddDataSeries(BarsPeriodType.Minute, 3);
                  
                              }
                  
                          }
                  
                  
                  
                          protected override void OnBarUpdate()
                  
                          {
                  
                              if (CurrentBars[0] < 10 || CurrentBars[1] < 10) return;
                  
                  
                  
                              if (BarsInProgress == 0)
                  
                              return;
                  
                  
                  
                              Stochastics1 = Stochastics(Closes[1],9, 12, 2);
                  
                              EMA1 =EMA(Closes[1], 50);
                  
                              if ((CrossAbove(Stochastics1.K, Stochastics1.D, 1)) && (Closes[1][0] > EMA1[0]) && (Stochastics1.K[0] < 65))
                  
                              {
                  
                                  Draw.ArrowUp(this,  CurrentBar.ToString(), true, 0, Low[0]-5*TickSize, Brushes.Green);
                  
                              }
                  
                          }
                  
                      }
                  
                  }
                  
                  #region NinjaScript generated code. Neither change nor remove.
                  
                  namespace NinjaTrader.NinjaScript.Indicators
                  {
                      public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
                      {
                          private CylceLowArrow[] cacheCylceLowArrow;
                          public CylceLowArrow CylceLowArrow()
                          {
                              return CylceLowArrow(Input);
                          }
                  
                          public CylceLowArrow CylceLowArrow(ISeries<double> input)
                          {
                              if (cacheCylceLowArrow != null)
                                  for (int idx = 0; idx < cacheCylceLowArrow.Length; idx++)
                                      if (cacheCylceLowArrow[idx] != null &&  cacheCylceLowArrow[idx].EqualsInput(input))
                                          return cacheCylceLowArrow[idx];
                              return CacheIndicator<CylceLowArrow>(new CylceLowArrow(), input, ref cacheCylceLowArrow);
                          }
                      }
                  }
                  
                  namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
                  {
                      public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
                      {
                          public Indicators.CylceLowArrow CylceLowArrow()
                          {
                              return indicator.CylceLowArrow(Input);
                          }
                  
                          public Indicators.CylceLowArrow CylceLowArrow(ISeries<double> input )
                          {
                              return indicator.CylceLowArrow(input);
                          }
                      }
                  }
                  
                  namespace NinjaTrader.NinjaScript.Strategies
                  {
                      public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
                      {
                          public Indicators.CylceLowArrow CylceLowArrow()
                          {
                              return indicator.CylceLowArrow(Input);
                          }
                  
                          public Indicators.CylceLowArrow CylceLowArrow(ISeries<double> input )
                          {
                              return indicator.CylceLowArrow(input);
                          }
                      }
                  }
                  
                  #endregion

                  Comment


                    #10
                    Hello lenmat,

                    Thanks for your reply.

                    When you draw the arrow, save the value of CurrentBar into an integer variable. As part of your conditions to draw the arrow, add a check that the CurrentBar is not equal to the value of the variable you saved CurrentBar into. This will have the effect of allowing 1 arrow (the first drawn arrow) per 3 minute bar.

                    For example, using an integer variable previously declared as private int savedBar;

                    if (your conditions && CurrentBar != savedBar)
                    {
                    Draw....
                    savedBar = CurrentBar; // save the bar number
                    }
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you Paul, this appears to be working perfectly now, thanks for all the help!

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by JoMoon2024, Today, 06:56 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post JoMoon2024  
                      Started by Haiasi, 04-25-2024, 06:53 PM
                      2 responses
                      17 views
                      0 likes
                      Last Post Massinisa  
                      Started by Creamers, Today, 05:32 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post Creamers  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      12 responses
                      1,786 views
                      0 likes
                      Last Post Leafcutter  
                      Started by poplagelu, Today, 05:00 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post poplagelu  
                      Working...
                      X