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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    132 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X