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 usazencort, Today, 01:16 AM
          0 responses
          1 view
          0 likes
          Last Post usazencort  
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          603 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          22 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          21 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          230 views
          0 likes
          Last Post TradingLoss  
          Working...
          X