Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    11 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    10 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    11 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,981 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Yesterday, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X