Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Drawing a line

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

    Drawing a line

    hi,

    i'm trying to figure out how i can draw a line from point A to point B.

    Point A = beginning equity
    Point B = ending equity

    background;

    I'm trying to figure out a way to rank my output from strategy analyzer using a custom variable within a strategy because i've got a great system but I have too many outputs and their associate variables for the strategy that give me different equity curves. Some equity curves are smooth and some explode and so on. R2 and standard deviation are just not enough as they adjust to data points.

    So what I am trying to do is:

    -draw a straight line from Point A to Point B at time T
    - then lookback and subtract the equity curve from the line at every point along the line from the equity curve (TradePerformance.Cum)
    - then sum the differences at time T

    Any suggestions?

    Thank you

    #2
    :Hello staycool3_a,

    Thanks for your post.

    A line can be drawn using Draw.Line where you can specify where you would want to draw a line specifying time/bars ago indexes and price.

    Drawing tools have anchors that hold price and time values for start/end points, however they do not have values for the entire line. I would recommend using an array to hold those values for your equity curve math.

    Subtracting the price values of the line's anchors could be done to get the difference (if I understand correctly, you are referring to a vertical line.)

    Documentation and sample code for using Draw.Line() can be found here - https://ninjatrader.com/support/help.../draw_line.htm

    Documentation for a Line object can be found here - https://ninjatrader.com/support/help...en-us/line.htm

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      :Hello staycool3_a,

      Thanks for your post.

      A line can be drawn using Draw.Line where you can specify where you would want to draw a line specifying time/bars ago indexes and price.

      Drawing tools have anchors that hold price and time values for start/end points, however they do not have values for the entire line. I would recommend using an array to hold those values for your equity curve math.

      Subtracting the price values of the line's anchors could be done to get the difference (if I understand correctly, you are referring to a vertical line.)

      Documentation and sample code for using Draw.Line() can be found here - https://ninjatrader.com/support/help.../draw_line.htm

      Documentation for a Line object can be found here - https://ninjatrader.com/support/help...en-us/line.htm

      Please let us know if we can be of further assistance.
      Thanks Jim.

      Code:
      Draw.Line(this, "tag1", false, CurrentBars[0]-1, cum_profit, 0, cum_profit, Brushes.LimeGreen, DashStyleHelper.Dot, 2);
      Above does work for TradePerformance.Cum (atleast it compiles). Drawing a line from first day to present. But obviously I can't visually see this line. Is the above correct?

      Yea, I think I'm going to create a series that holds my cum.profit bc it might be easier to do a lookback and subtract the values.

      However, say a create a series that holds my cum.profit...and I am also able to draw a line. how would i subtract the values between the line and curve? How do I refference this curve's values?

      I don't think it would be easy as:
      difference = tag1[20 bars ago] - cum.profit[20 bars ago]

      how do I reference tag1 line?

      Comment


        #4
        Hello staycool3_a,

        Thanks for your post.

        Above does work for TradePerformance.Cum (atleast it compiles). Drawing a line from first day to present. But obviously I can't visually see this line. Is the above correct?
        Valid double values can be used for the price parameters to have them drawn. "Correct" would depend on your expected output.

        I would recommend first testing the drawing tool with some values that you know will display to get more familiar with using the drawing tool. I may also suggest using the AutoScale property and changing the DashStyle to DashStyleHelper.Solid so you may observe solid lines and how AutoScale can bring the line into view.

        However, say a create a series that holds my cum.profit...and I am also able to draw a line. how would i subtract the values between the line and curve? How do I reference this curve's values?
        The line's value would have to be fetched from a Line object's anchors, or from your array that holds the values along the line. An equity curve or something that is plotted from an indicator would have to have the strategy add that indicator, and then you can reference that indicator's plot within your strategy. You may use the Strategy Builder to create some simple syntax for adding indicators and referencing indicator plots.

        how do I reference tag1 line?
        Please see the documentation on the Line object. You would create a Line and assign it with Draw.Line() and then the anchors of that line can be referenced to get the price level of that anchor.

        Please let us know if there is anything else we can do to help.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, Today, 06:53 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottWalsh, Today, 06:52 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottW, Today, 06:09 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ftsc2022, 10-25-2022, 12:03 PM
        5 responses
        256 views
        0 likes
        Last Post KeyonMatthews  
        Started by Board game geek, 10-29-2023, 12:00 PM
        14 responses
        244 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Working...
        X