Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding Draw.Region to Darvas Indicator

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

    Adding Draw.Region to Darvas Indicator

    Dear Support,

    I have a modified version of default Darvas indicator for sharing here. But I have a minor issue before posting it.

    I am using a bool = false condition for painting the region gradient color. The indicator plots fine when the bool is set to false. However, when bool condition is set to true the indicator does not plot. The following is the logic.

    Code:
                if (paintRegion)
                {
                    LinearGradientBrush gradient = new LinearGradientBrush();
                    gradient.StartPoint = new Point( 0, 0 );
                    gradient.EndPoint = new Point( 1, 0 );
    
                    gradient.GradientStops.Add(new GradientStop(System.Windows.Media.Colors.Crimson, 0));    //Color for Bottom side of the candle
                    gradient.GradientStops.Add(new GradientStop(System.Windows.Media.Colors.DarkCyan, 1));    //Color for Top side of the candle            
    
                    Draw.Region(this, "Region1", CurrentBar, 0, boxTopSeries, boxBottomSeries, Brushes.Transparent, gradient, Zopacity,0);
    
                    gradient.Freeze();                
                }
    Any idea why the bool condition = true prevents the indicator from plotting. Does the gradient brush need serialization similar to regular custom brushes? I have not serialized the gradient brush.

    Many Thanks.

    #2
    Hello aligator,

    Improper serialization would cause a public variable to not be saved in Xml such as workspaces or templates.

    Are you certain that the code is being reached?
    (Have you added a print?)

    Does the other Draw.Region() outside of this condition also use Brushes.Transparent?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello aligator,

      Improper serialization would cause a public variable to not be saved in Xml such as workspaces or templates.

      Are you certain that the code is being reached?
      (Have you added a print?)

      Does the other Draw.Region() outside of this condition also use Brushes.Transparent?
      Thanks Chelsea,

      Not quite sure what to print. The code works fine when the bool paintRegion = false. When set to true nothing plots.

      No, I Brushes.Transparent is not used out side this condition. Here is the file if you care please.

      Many thanks.
      Last edited by aligator; 07-06-2020, 11:34 PM.

      Comment


        #4
        Hello aligator,

        You could Print(Time[0]); to see on which bars the condition is true.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        When the bool is false, no region is drawn but the Upper and Lower plots are appearing.
        When the bool is true, the Upper and Lower plots do not appear, is this correct?

        Is there an error appearing on the Log tab of the Control Center when the script is reloaded?
        Last edited by NinjaTrader_ChelseaB; 07-07-2020, 08:13 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello aligator,

          You could Print(Time[0]); to see on which bars the condition is true.

          Below is a link to a forum post that demonstrates how to use prints to understand behavior.
          https://ninjatrader.com/support/foru...121#post791121

          When the bool is false, no region is drawn but the Upper and Lower plots are appearing.
          When the bool is true, the plots do not appear, is this correct?

          Is there an error appearing on the Log tab of the Control Center when the script is reloaded?
          Thanks you Chelsea,

          I was using the wrong ISeries for the region. The correct ISeries are Upper and Lower as shown below, not boxTopSeries and boxBottomSeries in post#1.

          Code:
          Draw.Region(this, "Region", CurrentBar, 0, Upper, Lower, Brushes.Transparent, gradient, Zopacity,0);
          This works fine now but I do not get a gradient effect between the lower and upper bands. I want an effect similar to gradient bars where the region color is Crimson at the bottom and gradually changes to DarkCyan at the top.
          ​​​ Thanks.
          Attached Files
          Last edited by aligator; 07-07-2020, 01:58 AM.

          Comment


            #6
            Hello aligator,

            From my understanding the gradient WPF brush is not converted to a SharpDX gradient brush in the drawing tool code.

            You would need to make your own drawing tool script and create a SharpDX gradient.


            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by andrewtrades, Today, 04:57 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            6 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            436 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            9 views
            0 likes
            Last Post FAQtrader  
            Started by rocketman7, Today, 09:41 AM
            5 responses
            20 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X