Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ArrowDown does not draw on 5 min timeframe

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

    ArrowDown does not draw on 5 min timeframe

    Hi All,

    I am trying to create a very simple indicator to draw arrows under a certain condition.

    Something very strange (to me) is happening. It will work on most minute based time frames, except the 5 minute, which is the one I trade against.

    I used the indicator wizard to generate the code below and just added the one line of code (in Blue).

    Does anyone have an idea what I am doing wrong?

    Thanks.





    namespace NinjaTrader.NinjaScript.Indicators.MyIndicators
    {
    public class MyThreeBarReversal : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "MyThreeBarReversal";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.

    if(High[2] > High[3]) Draw.ArrowDown(this, CurrentBar.ToString(),true,0, High[0] + TickSize, Brushes.Salmon);
    }
    }
    }

    #region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private MyIndicators.MyThreeBarReversal[] cacheMyThreeBarReversal;
    public MyIndicators.MyThreeBarReversal MyThreeBarReversal()
    {
    return MyThreeBarReversal(Input);
    }

    public MyIndicators.MyThreeBarReversal MyThreeBarReversal(ISeries<double> input)
    {
    if (cacheMyThreeBarReversal != null)
    for (int idx = 0; idx < cacheMyThreeBarReversal.Length; idx++)
    if (cacheMyThreeBarReversal[idx] != null && cacheMyThreeBarReversal[idx].EqualsInput(input))
    return cacheMyThreeBarReversal[idx];
    return CacheIndicator<MyIndicators.MyThreeBarReversal>(ne w MyIndicators.MyThreeBarReversal(), input, ref cacheMyThreeBarReversal);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal()
    {
    return indicator.MyThreeBarReversal(Input);
    }

    public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal(ISeries<double> input )
    {
    return indicator.MyThreeBarReversal(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal()
    {
    return indicator.MyThreeBarReversal(Input);
    }

    public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal(ISeries<double> input )
    {
    return indicator.MyThreeBarReversal(input);
    }
    }
    }

    #endregion






    #2
    Hello Seneca,

    Thank you for your post.

    I believe the issue is that you're not checking to make sure you have enough bars to process your condition and that is causing an error which leads to the indicator not plotting. I suspect if you check in the Log tab of the Control Center you'll see it's been throwing errors to the effect of "Error on calling 'OnBarUpdate' method on bar 0".

    To fix this, simply add a check to make sure you have at least three bars before you start calculating at the beginning of OnBarUpdate, since 3 is the largest number of bars this needs to look back to calculate:

    Code:
            protected override void OnBarUpdate()
            {
                if(CurrentBar < 3)
                    return;
    
                if(High[2] > High[3]) 
                {
                    Draw.ArrowDown(this, CurrentBar.ToString(),true,0, High[0] + TickSize, Brushes.Salmon);
                }
            }
    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Hi Kate,

      Awesome and many thanks! That was exactly the problem.

      Comment


        #4
        Hello I am using strategy builder and trying to add arrow drawing, i am having 2 issues


        Draw.ArrowDown(this, CurrentBar.ToString(),true,0, High[0] + TickSize, Brushes.Salmon)

        your example above, when i change Y to " HIgh[0] + TickSize," i do get the plot as expected, but when return to strategy builder I still see my code for Y as before

        but if i open the line of code to edit the Y has returned to default of 0 and the reference previously change to " HIgh[0] + TickSize," is not longer shown

        2nd item is how do I get this arrow to plot historically instead of ONLY on the last instance

        Thanks

        Comment


          #5
          Great video by PaulH to help with this


          2nd item resolve with video, but my Y still reverts to default of 0 and does not remain as shown in Paul Video

          Comment


            #6
            Hello DTSSTS,

            Thank you for your reply.

            As far as the Y reverting to 0, we've sent this to our development team to take a look at. This is being tracked under the number TS-2589. I'll let you know what our dev team says when I hear anything. In the meantime, if you need to edit the Drawing Object, you'll need to reset the Y value again.

            Thanks in advance; I look forward to assisting you further.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            598 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 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
            557 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            555 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X