• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting trend line value in strategy

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

    Getting trend line value in strategy

    Hi all,

    is it possible to retrieve graphical object values in strategy, especially trend line?

    My objective is to send orders when price cross some trend lines I set up manually.

    I know this is possible on other platforms but is it possible on NinjaTrader?

    Many Thanks!

    #2
    AlgoNaut,

    Yes, this is possible.

    For example, if you use :

    Code:
    IRay trendLine = DrawRay("tag1", 10, 1000, 0, 1001, Color.LimeGreen);
    You can access the "trendLine" object the following way :

    Code:
    trendLine.Anchor1BarsAgo  //An int value representing the number of bars ago of the 1st anchor point
    
    trendLine.Anchor1Time  //A DateTime structure representing the time of the 1st anchor point
    
    trendLine.Anchor1Y  //A double value representing the y value of the 1st anchor point
    
    trendLine.Anchor2BarsAgo  //An int value representing the number of bars ago of the 2nd anchor point
    
    trendLine.Anchor2Time //A DateTime structure representing the time of the 2nd anchor point
    
    trendLine.Anchor2Y   //A double value representing the y value of the 2nd anchor point
    
    trendLine.Pen   //The Pen object used to draw the object
    DrawRay() : http://www.ninjatrader.com/support/h...ml?drawray.htm

    IRay class : http://www.ninjatrader.com/support/h....html?iray.htm

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks a lot for your help.

      Do we need to draw it on the strategy and then modify it manually or can we first draw it manually on the chart and use these lines afterr on the strtaegy (thanks to the tag number for exemple).

      Comment


        #4
        AlgoNaute,

        The example I gave you would only work for programmatically drawn objects without an extra step. If you want to use manually drawn objects you need to be able to grab the IRay objects on your chart, identify the one you want the strategy to use by tag, then you can modify it or access its internal variables.

        Here is a sample of an indicator that alerts you when the price crosses a manually drawn line.

        http://www.ninjatrader.com/support/f...d=4&linkid=472

        You could adapt this for your purposes into a strategy.

        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Perfect.
          Thanks Adam.

          Comment


            #6
            AlgoNaute,

            No problem.

            Please don't hesitate to contact us should you require additional assistance.
            Adam P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by JTizz, Today, 08:59 AM
            0 responses
            3 views
            0 likes
            Last Post JTizz
            by JTizz
             
            Started by GTBrooks, Today, 08:28 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by manxtrader75, Yesterday, 11:42 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_ChristopherD  
            Started by julifro, Today, 08:24 AM
            0 responses
            2 views
            0 likes
            Last Post julifro
            by julifro
             
            Started by GTBrooks, Yesterday, 05:53 PM
            2 responses
            19 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X