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.



        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 adeelshahzad, Today, 03:54 AM
            5 responses
            32 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by stafe, 04-15-2024, 08:34 PM
            7 responses
            32 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by merzo, 06-25-2023, 02:19 AM
            10 responses
            823 views
            1 like
            Last Post NinjaTrader_ChristopherJ  
            Started by frankthearm, Today, 09:08 AM
            5 responses
            21 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            43 views
            0 likes
            Last Post jeronymite  
            Working...
            X