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 usazencortex, Today, 12:43 AM
            0 responses
            2 views
            0 likes
            Last Post usazencortex  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            168 responses
            2,262 views
            0 likes
            Last Post sidlercom80  
            Started by Barry Milan, Yesterday, 10:35 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by WeyldFalcon, 12-10-2020, 06:48 PM
            14 responses
            1,429 views
            0 likes
            Last Post Handclap0241  
            Started by DJ888, 04-16-2024, 06:09 PM
            2 responses
            9 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Working...
            X