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 Display Problem

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

    Indicator Display Problem

    Hi, I've created this code in the strategy wizard, applied it to an indicator. However, the indicator does not work when I apply it, but I know the code is good b/c it works as a strategy. Any help is much appreciated...

    Here is the code:

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    // Condition set 1
    if (Open[1] > Close[1]
    && Open[2] > Close[2]
    && Open[3] > Close[3])
    {
    DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
    }

    }

    #region Properties

    #endregion


    Regards,

    Brian

    #2
    Hello,

    In indicators you need to do a CurrentBar check. This link will help:


    You need to add if(CurrentBar < 3) return; after OnBarUpdate().
    DenNinjaTrader Customer Service

    Comment


      #3
      Still can't get it to work. It's strange, b/c it works on my TICK chart, but it dosen't work on a chart of the S&P contaract...Here's the updated code: /// /// Called on each bar update event (incoming tick) /// protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. // Condition set 1 if (CurrentBar < 3) return; if (Open[1] > Close[1] && Open[2] > Close[2] && Open[3] > Close[3]) { DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime); } }

      Comment


        #4
        Hello,


        Try using this code, which I tested and works if you paste it within the OnBarUpdate() block:

        if
        (CurrentBar < 3) return;

        if (Open[1] > Close[1]
        && Open[
        2] > Close[2]
        && Open[
        3] > Close[3])
        {
        DrawArrowUp(
        "tag1" + CurrentBar, true, 0, Low[0] - TickSize, Color.Red);
        }
        DenNinjaTrader Customer Service

        Comment


          #5
          Got it Ben... Tks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          939 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          7 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          4 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          28 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          33 views
          0 likes
          Last Post wzgy0920  
          Working...
          X