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 dtaylor, 08-07-2022, 09:43 PM
            7 responses
            593 views
            0 likes
            Last Post Emma1
            by Emma1
             
            Started by RubenCazorla, Yesterday, 03:23 AM
            2 responses
            21 views
            0 likes
            Last Post RubenCazorla  
            Started by Rudmax, 07-02-2024, 05:40 AM
            30 responses
            430 views
            1 like
            Last Post Rogue_Two  
            Started by Bobin, 03-12-2024, 08:51 AM
            22 responses
            745 views
            0 likes
            Last Post Schfifty005  
            Started by CrissCross, Today, 01:34 PM
            1 response
            19 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X