Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator does not display on price panel except when set to a minute chart

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

    Indicator does not display on price panel except when set to a minute chart

    below is my indicator code. the code draws dots correctly on a minute chart. however, any other chart type they disappear and i cant figure out why. below is my indicator code. any help is appreciated.

    namespace NinjaTrader.NinjaScript.Indicators.MyIndicators {
    public class MyPivotIndicator : Indicator, IOnBarUpdateReady {

    public event EventHandler<EntryAlertEventArgs> EntryAlertEvent;
    private void RaiseEntryAlertEvent(PositionDirection direction) {
    var price = new Price(GetPriceToEnterTrade(direction), CurrentBar);
    EventHandler<EntryAlertEventArgs> handler = EntryAlertEvent;
    if (handler != null)
    handler(this, new EntryAlertEventArgs(direction, price));
    }
    protected override void OnStateChange() {
    if (State == State.SetDefaults) {
    Description = @"Alerts when a pivot is complete.";
    Name = "MyPivotIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = false;
    }
    else if (State == State.Configure) {
    ClearOutputWindow();
    }
    }
    protected override void OnBarUpdate() {
    if (!IsOnBarUpdateReady())
    return;
    SetSupportPivot();
    SetResistancePivot();
    }
    private void SetResistancePivot() {
    var afterPivot = High[0];
    var pivot = High[1];
    var beforePivot = High[2];
    var pivotBarIndex = CurrentBar - 1;

    if (beforePivot <= pivot && pivot > afterPivot) {
    Draw.Dot(this, "resistanceDot" + pivotBarIndex, true, 1, pivot, Brushes.Red, true);
    RaiseEntryAlertEvent(PositionDirection.Short);
    }
    }
    private void SetSupportPivot() {
    var afterPivot = Low[0];
    var pivot = Low[1];
    var beforePivot = Low[2];
    var pivotBarIndex = CurrentBar - 1;

    if (beforePivot >= pivot && pivot < afterPivot) {
    Draw.Dot(this, "supportDot" + pivotBarIndex, true, 1, pivot, Brushes.LimeGreen, true);
    RaiseEntryAlertEvent(PositionDirection.Long);
    }
    }
    public bool IsOnBarUpdateReady() { return (High.Count > 2 && Low.Count > 2); }
    }
    }​

    #2
    Hello love2code2trade,

    Thank you for your post.

    IOnBarUpdateReady is not an NinjaTrader class we are familiar with and may not be necessary.

    Are there any errors appearing on the Log tab of the Control Center?

    In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating.

    Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

    https://ninjatrader.com/support/foru...121#post791121

    Print the time of the bar and all values used in the conditions, include labels for all values and comparison operators.

    Let me know if you need any assistance creating a print.

    Save the output from the output window to a text file and provide this with your reply.

    I'll be happy to assist with analyzing the output.

    Comment

    Latest Posts

    Collapse

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