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

Draw.Region displacing shading incorrectly

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

    Draw.Region displacing shading incorrectly

    Hello:

    I am working on developing an indicator based on two moving averages. The values are stored in Value[0] (plotUp) and Value[1] (plotDown). I am using IF statements to alter the color of these lines based upon weather one is above the other. The lines for these values are plotted correctly, and the color of the lines are also correct.

    I am attempting to use the same color pattern to shade the area between the two line, again, alternating the color based on weather one line is above another. I am using Draw.Region for this purpose. The color of the shading is correct, however, its not shading between the lines. It looks displaced to the left for some reason. The same values that I am using to draw the lines are being passed into the Draw.Region method. I have modified the values in the StartBarsago and endBarsAgo variables and it doesn't seem to change its placement.

    Here is the code:

    if (plotDown >= plotUp)
    {
    Draw.Region(this, "ePlotDn", CurrentBar, 0,plotDown, plotUp,null, _downColor, _DownOpacity);
    }
    else
    {
    Draw.Region(this, "ePlotUp", CurrentBar, 0, plotUp, plotDown, null, _upColor, _UpOpacity);
    }
    Here is a screen Shot:


    Click image for larger version  Name:	jelQ2Region.png Views:	2 Size:	253.6 KB ID:	1047311
    Attached Files
    Last edited by jeliner; 02-06-2019, 10:20 AM.

    #2
    Hello jeliner,

    Thanks for your post.

    I suspect the issue is Value[1] as this would be the previous bar of Value[0] and if that were the case then this would mean that you are using the method overload that uses a series and a double and the last parameter is displacement. Please use Values[1] as the second data series.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello jeliner,

      Thanks for your post.

      I suspect the issue is Value[1] as this would be the previous bar of Value[0] and if that were the case then this would mean that you are using the method overload that uses a series and a double and the last parameter is displacement. Please use Values[1] as the second data series.
      Nothing changed Weather I use Values[1] or plotDown - Values[0] or plotUp. It was a Type-O above... I forgot the "s" in the first sentence when I was saying that the lines plot correctly. I just wanted to show that the variables of plotUp and plotDown match to the corresponding Values[0] and Values[1] through properties.

      I have the following set in properties to show how the Values[1] is plotDown and Values[0] is plotUp


      [Browsable(false), XmlIgnore]

      public Series<double> plotUp

      {

      get { return Values[0]; }

      }



      [Browsable(false), XmlIgnore]

      public Series<double> plotDown

      {

      get { return Values[1]; }

      }

      Last edited by jeliner; 02-06-2019, 10:40 AM.

      Comment


        #4
        Hello jeliner,

        Thanks for your reply.

        Typos aside then there is not enough information to determine the issue.

        Can you attach your entire code or a working example of the code you are using that demonstrates the issue? If you would prefer you are welcome to write into PlatformSupport[a]NinjaTrader[dot]com with your code and mark the e-mail atten:Paul and add a link to this thread in the body of the e-mail.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_PaulH View Post
          Hello jeliner,

          Thanks for your reply.

          Typos aside then there is not enough information to determine the issue.

          Can you attach your entire code or a working example of the code you are using that demonstrates the issue? If you would prefer you are welcome to write into PlatformSupport[a]NinjaTrader[dot]com with your code and mark the e-mail atten:Paul and add a link to this thread in the body of the e-mail.
          Hello Mr Paul.

          I am following up on email I received from you concerning this issue. You are correct that changing Displacement = 0 in OnChangeState (SetDaults) fixed the problem and the shading is appearing in the proper place. How would I make the shading appear in the proper place if I wish to use displacement?

          Comment


            #6
            Hello jeliner,

            Thanks for your reply.

            You will need to use the method overload for Draw.Region that uses displacement as a parameter. Reference: https://ninjatrader.com/support/help...raw_region.htm

            From your code, I changed to this: Draw.Region(this, "ePlotDn", CurrentBar, -1, plotDown, plotNeutral, null, _downColor, _DownOpacity, Displacement);

            That change will allow the user to specify further displacement from the UI, unless you prefer not to do it that way and in that case simply make it a private variable or a fixed value.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_PaulH View Post
              Hello jeliner,

              Thanks for your reply.

              You will need to use the method overload for Draw.Region that uses displacement as a parameter. Reference: https://ninjatrader.com/support/help...raw_region.htm

              From your code, I changed to this: Draw.Region(this, "ePlotDn", CurrentBar, -1, plotDown, plotNeutral, null, _downColor, _DownOpacity, Displacement);

              That change will allow the user to specify further displacement from the UI, unless you prefer not to do it that way and in that case simply make it a private variable or a fixed value.
              WOW! I cant believe I missed that overload option in the documentation! Thanks for the help - this is working like I want it too!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by funk10101, Today, 09:43 PM
              0 responses
              6 views
              0 likes
              Last Post funk10101  
              Started by pkefal, 04-11-2024, 07:39 AM
              11 responses
              37 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Yesterday, 08:51 AM
              8 responses
              44 views
              0 likes
              Last Post bill2023  
              Started by yertle, Today, 08:38 AM
              6 responses
              26 views
              0 likes
              Last Post ryjoga
              by ryjoga
               
              Started by algospoke, Yesterday, 06:40 PM
              2 responses
              24 views
              0 likes
              Last Post algospoke  
              Working...
              X