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 NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    68 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X