Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Arrows not working

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

    Draw Arrows not working

    Hello,

    OK, so I am kind of new to c#, but have enough 'coding' background to be able to grasp things pretty well.

    I tried creating a simple indicator that draws arrows above and below bars that are overbought and oversold. However without the second and statements, the arrows would plot on every bar that was ob or os.

    // Condition set 1
    if (RSI(5, 1)[0] >= 80 &&
    RSI(5, 1)[1] < 80)
    {
    DrawArrowDown("My down arrow" + CurrentBar, false, 0, High[0] + 2 * TickSize, Color.Red);
    }


    // Condition set 2
    if (RSI(5, 1)[0] <= 20 &&
    RSI(5, 1)[1] > 20)
    {

    DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + -2 * TickSize, Color.Lime);
    }
    When I remove just the second condition for Condition Set 2 (the oversold case) and leaving Condition Set 1 as above, the indicator works fine, but with all conditions laid out, nothing is drawn on the chart.

    // Condition set 2
    if (RSI(5, 1)[0] <= 20)
    {

    DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + -2 * TickSize, Color.Lime);
    }
    Would really appreciate some help on this

    Asim

    #2
    The second condition of each condition set is a must. So why do you want to remove it?

    Thanks
    Pi
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #3
      I don't want to remove it. That's the point. It doesn't work with my full condition set at all But only works when I behin to remove the second condition on the second set.

      Comment


        #4
        Have you checked this:

        if (CurrentBar == 0) return;

        Please put it at the very first line in OnBarUpdate.

        Thanks,
        Pi
        Last edited by ninZa; 12-14-2014, 05:26 AM.
        ninZa
        NinjaTrader Ecosystem Vendor - ninZa.co

        Comment


          #5
          Ah, thanks it works now.

          Didn't realise I needed such a line, as I was calculating/updating on bar close.

          Asim

          Comment


            #6
            Do you realize that you refer to the RSI value of 1 bar ago: RSI(5, 1)[1]
            However, obviously at CurrentBar = 0 you have no bars before it to get the RSI value, which caused the error.

            You should regularly monitor the Log tab (from the Control Center) to look for errors and hints

            Cheers,
            Pi
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #7
              lol my bad I thought the currentBar was the right most bar i.e. the latest bar, rather than the left most bar. (Different platforms allocate numbers differently, so got mixed up).

              Comment


                #8
                Ya, that is the point.
                ninZa
                NinjaTrader Ecosystem Vendor - ninZa.co

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                647 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X