Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRegion question

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

    DrawRegion question

    hi,
    i am trying to color the region above the bollinger band green when the 30ema>60ema, & red when the 30ema<60ema, using "if "& "else" statements.
    the chart when refreshed does the job except when you move it...then it goes all green above the bollinger band & the red disappears ?? the upper, middle & lower bands were set to tranparent on the chart. here's my attempt & thanks for any help.



    protectedoverridevoid OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    Upperband.Set(SMA(Period)[0] + NumStdDev * StdDev(Period)[0]);
    Middleband.Set(SMA(Period)[
    0]);
    Lowerband.Set(SMA(Period)[
    0] - NumStdDev * StdDev(Period)[0]);
    {
    if (EMA(30)[0] > EMA(60)[0])
    DrawRegion(
    "tag1", CurrentBar, 0, Bollinger(NumStdDev, Period).Upper, 1000000, Color.Empty, Color.Lime, 2);
    else
    DrawRegion("tag1", CurrentBar, 0, Bollinger(NumStdDev, Period).Upper, 1000000, Color.Empty, Color.LightSalmon, 2);
    }
    }
    Last edited by upsndowns; 06-03-2010, 04:12 AM. Reason: unnecessary line

    #2
    upsndowns, please try using a different tag id for each DrawRegion used.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I made a customization to keltner channel indicator so that the area between upper and lower bands is filled with a color. This was working fine with NinjaTrader version 7 beta 20. But after upgrading to v7 beta 21, I cannot see any price bars on the chart if this indicator is present.

      If I remove the DrawRegion line in indicator code (snippet below) then I can see price bars etc on the chart. Could you please let me know what is wrong with this code snippet (note: this was working with beta 20 and prior beta versions upto 16).

      DrawRegion("tag1", CurrentBar, 0, AKC(offsetMultiplier, Period).Upper, AKC(offsetMultiplier, Period).Lower, Color.Empty, Color.SlateBlue, 1);

      Comment


        #4
        This looks ok to me - could you perhaps attach the indicator in full so I can test it here on B21? Are you setting any ScaleJustification progammatically in there?

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Problem with DrawRegion API in beta 21

          Bertrand,
          Attachment has the indicator (ColorKeltnerChannel) that stopped working with beta version 21.

          The only difference between this and default KeltnerChannel indicator code is one line:

          DrawRegion("KCColorTag", CurrentBar, 0, ColorKeltnerChannel(offsetMultiplier, Period).Upper, ColorKeltnerChannel(offsetMultiplier, Period).Lower, Color.Empty, Color.SlateBlue, 1);


          Regards
          Last edited by atrader123; 02-03-2011, 11:13 AM.

          Comment


            #6
            Please try this changed line to reference the series directly, no recursive self reference then - which should work as I tested here -

            DrawRegion("KCColorTag", CurrentBar, 0, Upper, Lower, Color.Empty, Color.SlateBlue, 1);
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Excellent. It worked.

              Thanks

              Comment


                #8
                Great, thanks for reporting back here.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by t.kelly4149, Today, 05:36 PM
                1 response
                5 views
                0 likes
                Last Post bltdavid  
                Started by SilverSurfer1, Today, 06:29 PM
                0 responses
                14 views
                0 likes
                Last Post SilverSurfer1  
                Started by trader3000a, Today, 01:06 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by marcus2300, Today, 11:45 AM
                3 responses
                30 views
                0 likes
                Last Post marcus2300  
                Started by pel11, Today, 11:06 AM
                0 responses
                12 views
                0 likes
                Last Post pel11
                by pel11
                 
                Working...
                X