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

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 love2code2trade, 04-17-2024, 01:45 PM
                4 responses
                37 views
                0 likes
                Last Post love2code2trade  
                Started by alifarahani, Today, 09:40 AM
                2 responses
                13 views
                0 likes
                Last Post alifarahani  
                Started by junkone, Today, 11:37 AM
                3 responses
                18 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by pickmyonlineclass, Today, 12:23 PM
                0 responses
                3 views
                0 likes
                Last Post pickmyonlineclass  
                Started by frankthearm, Yesterday, 09:08 AM
                12 responses
                44 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Working...
                X