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 not responding to code logic

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

    DrawRegion not responding to code logic

    In the attached chart, I want the DrawRegion between the Gold lines BB 8/.8 to change based on the conditions in the code. They don't. To check the logic, I add BackColor (just for troubleshooting) which shows that the logic is correct.

    How do I accomplish this?

    Here is the code in question: (I've also attached the entire indicator in case you need it)

    // fill the bands with color and allow for custom opacity level

    if (
    (Close[0] > UpperBB8[0] && SMA(8)[0] > SMA(20)[0]) ||
    (Close[0] > SMA(8)[0] && Rising(SMA(20)))
    )
    {
    DrawRegion("BB8", CurrentBar, 0, UpperBB8, LowerBB8, Color.Empty, longColor, OpacityBB8);
    BackColor = Color.PaleTurquoise;
    }

    else if (
    (Close[0] < LowerBB8[0] && SMA(8)[0] < SMA(20)[0]) ||
    (Close[0] < SMA(8)[0] && Falling(SMA(20)))
    )
    {
    BackColor = Color.PeachPuff;
    DrawRegion("BB8", CurrentBar, 0, UpperBB8, LowerBB8, Color.Empty, shortColor, OpacityBB8);
    }
    else {
    BackColor = Color.Transparent;
    DrawRegion("BB8", CurrentBar, 0, UpperBB8, LowerBB8, Color.Empty, Color.Empty, 0);
    }

    [Note: This is a messy way to paste in the code, but I don't know how to do it in its own window like I see in other posts... How do I do that? ]
    Attached Files

    #2
    Follow-on question to first post

    given how many times I reference items in various DataSeries, would it improve performance significantly if I created double variables to hold these values to use in the logic code?
    Last edited by saroj; 11-01-2009, 06:47 PM. Reason: misspelling

    Comment


      #3
      Hello,

      Have you seen this referenced showing how to do it:
      DenNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Ben View Post
        Hello,

        Have you seen this referenced showing how to do it:
        http://www.ninjatrader-support2.com/...ead.php?t=4331
        Ben, thanks for the link... turns out it was the final "else" and some anomaly of region painting that was causing the problems... however I'm so much a beginner at this NS/C3 stuff that I have spent hours today trying to understand why/how NT Josh made the coding decisions he did... I had started with a Bollinger Band region drawing example posted by Bertrand which uses very different constructs.

        All in a day's work I guess.

        Comment


          #5
          Hello,

          Yes, coding can be tedious, but once you get the logic down it gets faster and can even be fun.
          DenNinjaTrader Customer Service

          Comment


            #6
            Over the last few days, I have made several attempts to find a good example of DrawRegion, and at last I have found it.

            Have you seen this referenced showing how to do it:
            http://www.ninjatrader-support2.com/...ead.php?t=4331

            Thank you for the link to the sample code and equally important is an example of what the code will produce.
            Now I have one less hurdle to clear.

            Comment


              #7
              Here's my latest code (NT 7)

              ... for the Bollinger Band draw region example.

              Attached Files

              Comment


                #8
                Hello saroj,
                Thank you very much for the update. I have had only a brief look at the code and the sample output, but I can see where I will be able to learn several different ideas and the sample code snippets.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                5 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Started by alifarahani, Today, 09:40 AM
                6 responses
                41 views
                0 likes
                Last Post alifarahani  
                Started by Waxavi, Today, 02:10 AM
                1 response
                20 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X