Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

getting fib levels from secondary series

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

    getting fib levels from secondary series

    HI i am using this indicator that is from ecosystem and i am using this indicator in strategy with multi series.
    I put all code inside barsinprogress ==2 and fib levels are drawn at different levels then if i have drawn indicator on that chart.

    How can i make sure that fib levels get drawn at same levels on secondary series as i would place inicator on that chart series?

    Code:
    namespace NinjaTrader.NinjaScript.Indicators.TcF
    {
    
        public class TcFAutoFibos : Indicator
        {
    
    
            #region Variables
    
            private FibonacciRetracements fib;
            private MIN min;
            private MAX max;
            private int barsSinceHigh = -1, barsSinceLow = -1;        
    
            #endregion
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Automatically draw fibonacci retracements from swing highs and lows in the market.";
                    Name                                        = "TcFAutoFibos";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = true;
                    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;
                    Strength                    = 20;
                }
                else if (State == State.Configure)
                {
                    min=MIN(Low,Strength);
                    max=MAX(High,Strength);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (CurrentBar<Strength)
                    return;
    
                if (High[0]>max[1])
                    barsSinceHigh=0;
                else if (barsSinceHigh>-1 && IsFirstTickOfBar)
                    barsSinceHigh++;
    
                if (Low[0]<min[1])
                    barsSinceLow=0;
                else if (barsSinceLow>-1 && IsFirstTickOfBar)
                    barsSinceLow++;
    
                if (Math.Min(barsSinceHigh,barsSinceLow)<=0)
                    return;
    
                if (barsSinceHigh<barsSinceLow)            
                    fib=Draw.FibonacciRetracements(this,"fib",IsAutoScale,barsSinceLow,Low[barsSinceLow],barsSinceHigh,High[barsSinceHigh]);            
                else
                    fib=Draw.FibonacciRetracements(this,"fib",IsAutoScale,barsSinceHigh,High[barsSinceHigh],barsSinceLow,Low[barsSinceLow]);
            }
    
            #region Properties
            [Range(1, int.MaxValue)]
            [NinjaScriptProperty]
            [Display(Name="Strength", Order=1, GroupName="Parameters")]
            public int Strength
            { get; set; }
            #endregion
    
        }
    }​

    #2
    Hello tkaboris,

    Drawing objects bars ago are based on the primary series where they are rendered. You wouldn't be able to use secondary series in the same way as a chart series. For prices that you are using to know why the drawing is different you need to use prints to identify what is different when you run the script vs what you are trying to do manually on the chart. You can find details about using prints in the following link: https://ninjatrader.com/support/help...lightsub=print

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    47 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X