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 andrewtrades, Today, 04:57 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          5 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
          7 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X