Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tick replay and update on every tick indicators

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

    Tick replay and update on every tick indicators

    I have a couple of indicators that require tick replay = true

    The problem is that another indicator now only works on those charts with calculate on bar close. If it's set to update on every tick (with tick replay) it produces rubbish.

    I apologize if this is something really basic. I'm new to coding.



    Code:
       public class Locations : Indicator
    
        {
            private int Zero;
    
            private Brush Brush1;
            private Brush Brush2;
            private Brush Brush3;
            private Brush Brush4;
            private Brush Brush5;
            private Brush Brush6;
            private EMA EMA1;
            private EMA EMA2;
            private MABandsFixed MABandsFixed1;
            private NinjaTrader.NinjaScript.Indicators.GomPro.GomCD GomCD1;
            private EMA EMA3;
            private MABandsFixed MABandsFixed2;
    
            protected override void OnStateChange()
    
            {
                if (State == State.SetDefaults)
                {
                    Description                    = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionSMA;
                    Name                        = "Locations";
                    IsOverlay                    = false;
                    IsSuspendedWhileInactive    = false;
                    Zero                        = 0;
    
                }
                else if (State == State.Configure)
                {
                    Brush1 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D0603"));
                    Brush1.Freeze();
                    Brush2 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1F3954"));
                    Brush2.Freeze();
                    Brush3 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D0603"));
                    Brush3.Freeze();
                    Brush4 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1F3954"));
                    Brush4.Freeze();
                    Brush5 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1F3954"));
                    Brush5.Freeze();
                    Brush6 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D0603"));
                    Brush6.Freeze();
                }
                else if (State == State.DataLoaded)
                {                
                    EMA1                = EMA(Close, 20);
                    EMA2                = EMA(Close, 60);
                    MABandsFixed1 = MABandsFixed(Close, 1.5, 1, 20);
                    GomCD1             = GomCD(Close, Gom.DeltaLib.DeltaCalcType.BidAsk, true, -1, 0, Gom.CumulativeDelta.ChartType.CumulativeChart, false);
                    EMA3                 = EMA(GomCD1.DeltaClose, 20);
                    MABandsFixed2  = MABandsFixed(Close, 1.5, 1, 60);
                }
            }
            protected override void OnBarUpdate()
            {
    
            {
                    if (BarsInProgress != 0) 
                    return;
    
    
    
                 // Set 1
                if ((Close[0] < EMA1[0])
                     && (Close[0] < Open[0])
                     && (Close[0] < EMA2[0]))
                {
                    BackBrushAll = Brush1;
                }
    
    
                // Set 2
                if ((Close[0] > EMA1[0])
                     && (Close[0] > Open[0])
                     && (Close[0] > EMA2[0]))
                {
                    BackBrushAll = Brush2;
                }
    
                 //Set 3
                if ((Close[0] > MABandsFixed1.Upper[0])
                     && (Close[0] < Open[0])
                     && (GomCD1.DeltaClose[0] < EMA3[0]))
                {
                    BackBrushAll = Brush3;
                }
    
                 //Set 4
                if ((Close[0] < MABandsFixed1.Lower[0])
                     && (Close[0] > Open[0])
                     && (GomCD1.DeltaClose[0] > EMA3[0]))
                {
                    BackBrushAll = Brush4;
                }
    
                  //Set 5
                if ((Close[0] > Open[0])
                     && (Close[0] < MABandsFixed2.Lower[0])
                     && (Close[0] > EMA1[0]))
                {
                    BackBrushAll = Brush5;
                }
    
                 //Set 6
                if ((Close[0] > MABandsFixed2.Upper[0])
                     && (Close[0] < Open[0])
                     && (Close[0] < EMA1[0]))
                {
                    BackBrushAll = Brush6;
                }
    
    
    
                }











    #2
    Hello Sparkyboy,

    If the indicator was not programmed with using TickReplay in mind you would likely need to modify it to work as you wanted.

    If you need it to work OnBarClose, you could try to instead use IsFirstTickOfBar to simulate that when using OnEachTick. https://ninjatrader.com/support/help...FirstTickOfBar

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

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