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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          76 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          154 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          101 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          289 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X