Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Condition in combination with lines

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

    Condition in combination with lines

    Is it possible to add a condition to the close of a bar in combination with a coded extended line?

    For example:
    IF close[0] < Extended Line THEN
    Do something....

    Thanks.

    Regards,

    Gunnar

    #2
    Hello Gunnar,

    Thank you for writing in.

    Yes, this would be possible.

    You can accomplish this by assigning an IExtendedLine object to DrawExtendedLine() and then accessing the IExtendedLine object's StartY or EndY values.



    As an example:
    Code:
    IExtendedLine el = DrawExtendedLine("line", 0, Close[0], 10, Close[0], Color.Blue);
    
    if (Close[0] < el.StartY)
         // do something
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Dear Zachary,

      Thanks for the quick reply and your proposal.

      However, you suggestion will not work since StartY and EndY are fixed values from previous bars. When the extended line is sloping up, the value of the line at Time[0] will be bigger than the EndY value. That will be the value I'm interested in.

      Are there any other possibilities or do I have to create a workaround?

      Regards,

      Gunnar
      Last edited by Bruin813; 07-26-2016, 02:07 PM.

      Comment


        #4
        Hello Gunnar,

        You're right about that! I apologize.

        I'm figuring out a solution for you here. Thank you for your patience.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Hello Gunnar,

          Thank you for your patience.

          What I propose is finding the slope of your line and then adding that value to your initial endY value every time OnBarUpdate() is called.

          Here's an example:
          Code:
          private bool doOnce = false;
          private double slope;
          private double endY;
          
          protected override void OnBarUpdate()
          {
          	if (CurrentBar < 200)
          		return;
          
          	if (!doOnce)
          	{
          		DrawExtendedLine("line", true, 200, Close[200], 0, Close[0], Color.Blue, DashStyle.Solid, 1);
          		slope = (Close[0] - Close[200]) / 200;
          		endY = Close[0];
          		doOnce = true;
                          return;
          	}
          	endY += slope;
          	Print(Time[0] + " " + endY);
          }
          You can then use the endY variable for your comparison.
          Last edited by NinjaTrader_ZacharyG; 07-26-2016, 02:40 PM.
          Zachary G.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          65 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          41 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          23 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          26 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          52 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X