• 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 rickyblah12, Today, 01:01 PM
            0 responses
            8 views
            0 likes
            Last Post rickyblah12  
            Started by dadarara, Today, 12:18 PM
            0 responses
            8 views
            0 likes
            Last Post dadarara  
            Started by joemiller, Today, 07:33 AM
            2 responses
            12 views
            0 likes
            Last Post joemiller  
            Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
            7 responses
            38 views
            0 likes
            Last Post DaveS
            by DaveS
             
            Started by claxxical, Yesterday, 10:00 PM
            0 responses
            13 views
            0 likes
            Last Post claxxical  
            Working...
            X