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 wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          27 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 04-23-2024, 09:53 PM
          2 responses
          49 views
          0 likes
          Last Post wzgy0920  
          Started by Kensonprib, 04-28-2021, 10:11 AM
          5 responses
          193 views
          0 likes
          Last Post Hasadafa  
          Started by GussJ, 03-04-2020, 03:11 PM
          11 responses
          3,235 views
          0 likes
          Last Post xiinteractive  
          Working...
          X