Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

The value of the Extended line on any bar.

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

    The value of the Extended line on any bar.

    Hello everyone.

    How can I find out what is the value of "Extended line" on any bar or time I need?
    For example, how to find the value of this line on this bars below:
    Click image for larger version

Name:	Obj4.jpg
Views:	193
Size:	61.9 KB
ID:	1102052

    #2
    Hello webus,

    Thanks for your post.

    To determine the price level of the extendedLine, on each bar after the line has been drawn, you would need to project where the line will be. You can do this by using the slope of the line to calculate the run rate. Please see this thread for further information and an example: https://ninjatrader.com/support/foru...-the-drawn-ray

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_PaulH,

      Originally posted by NinjaTrader_PaulH View Post
      Hello webus,

      Thanks for your post.

      To determine the price level of the extendedLine, on each bar after the line has been drawn, you would need to project where the line will be. You can do this by using the slope of the line to calculate the run rate. Please see this thread for further information and an example: https://ninjatrader.com/support/foru...-the-drawn-ray
      I use some similar formula:
      Code:
                     double getPriceByBarOnLine (int x1, double y1, int x2, double y2, int new_x){
                        double k = (y1 - y2) / (x1 - x2);
                        double b = y2 - k * x2;
                        double price = k * new_x + b;
                        return price;
                     }
      but what if the Anchors are outside the formed candles (as in my screenshot)? In this case, we cannot find the price by the candle, am I right?
      What other options are there for this case?

      Comment


        #4
        Hello webus,

        Thanks for your reply.

        The selection dots on your screenshot show where the anchors are, they should be available to pull from the draw object.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi NinjaTrader_PaulH,

          Originally posted by NinjaTrader_PaulH View Post
          Hello webus,
          The selection dots on your screenshot show where the anchors are, they should be available to pull from the draw object.
          Ok let me explain step by step. We can find the value we need if we know the bar number and prices of each of the anchors, right?

          If the anchor is outside the CurrentBar, we can find out its Time, but we can’t find out the number of its bar, since this bar does not yet exist, right?
          BarsArray[0].GetBar(anchorTime) will return the value of CurrentBars[0], but this is not the right bar value of the rightmost anchor! (this is the case from my screenshot).

          So our methods are not suitable, agree?

          Comment


            #6
            Hello webus,

            Thanks for clarifying.

            It may be possible to pull the future anchor bar but it depends on the bar type (time based versus non time based) and generally wouldn't be a good practice.

            We recommend drawing your objects with anchor points within the bars themselves to avoid this, if possible.

            If not possible, a colleague has suggest you might look at the code of the indicator "Trendlines" where the slot indexes, not bars, are used.

            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cre8able, 02-11-2023, 05:43 PM
            3 responses
            235 views
            0 likes
            Last Post rhubear
            by rhubear
             
            Started by frslvr, 04-11-2024, 07:26 AM
            8 responses
            113 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Started by stafe, 04-15-2024, 08:34 PM
            10 responses
            45 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by rocketman7, Today, 09:41 AM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by traderqz, Today, 09:44 AM
            2 responses
            10 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X