• 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

transferring slope or angle to different time frames

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

    transferring slope or angle to different time frames

    I have been working a few days trying to figure how to get the angle on different time frames and everytime I draw the anchor line it is the wrong angle

    i extracted the informatio from a Ray line I have drawn.

    I am trying to get an angle on a daily chart then transfer the angle to a minute chart

    dTicks = dRayStartPrice - dRayEndPrice; //y coordinates RISE
    dTicks = dTicks / TickSize; // Divide by ticks for chart

    nResTime = nRayStartBar - nRayEndBar; // x coordinate number of bars

    dResAngle = dTicks / Convert.ToDouble(nResTime);

    dResAngle = dResAngle/tChartTimeFrameInMinutes;


    The chart time frame in minutes will find out the number of minutes if daily tcharttimeframe in minutes will be 1440


    when my function loads the resangle it is supposed to draw

    double dAnchor1 = 0;
    double dAnchor2 = 0;
    double dAnchor3 = 0;

    // check chart time frame if daily or weekly
    if (Regex.IsMatch(BarsPeriod.ToString(), "Daily") == true)
    tChartTimeFrameInMinutes = 1440;

    if (Regex.IsMatch(BarsPeriod.ToString(), "Weekly") == true)
    tChartTimeFrameInMinutes = 10080;



    DateTime tTempTime1 = tTime1;
    DateTime tTempTime2 = tTempTime1.AddMinutes(tChartTimeFrameInMinutes);

    dAnchor1 = Bars.GetOpen(Bars.GetBar(tTempTime1));

    dAnchor2 = (dResAngle * TickSize) *tChartTimeFrameInMinutes+ dAnchor1;
    dAnchor3 = -1 * (dResAngle * TickSize)*tChartTimeFrameInMinutes+ dAnchor1;

    DrawRay("InverseAngle", false, tTempTime1, dAnchor1, tTempTime2, dAnchor2, Color.Red, DashStyle.Dash, 2);
    DrawRay("AnchorLine", false, tTempTime1, dAnchor1, tTempTime2, dAnchor3, Color.Green, DashStyle.Dash, 2);
    this.tagList.Add(new TachEonForceDrawList("InverseAngle"));
    this.tagList.Add(new TachEonForceDrawList("AnchorLine"));



    it works well if it stays on daily chart but when to a 1 minute it is totally off and not the correct angle
    Last edited by ballboy11; 11-25-2017, 08:02 AM.

    #2
    Hello ballboy11,

    This thread will remain open for any community members that would like to assist with your custom math and logic.

    That said, there is a formula that I have saved in my notes that may be beneficial to you, however, this formula is not supported by NinjaTrader Support.

    Converting slope to angle:
    Code:
    Math.Atan2((startY - endY), numberOfBars) * (180 / Math.PI));
    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.


    That said, when debugging your code, are you finding that the prints of the start and end bars and prices are expected values when changing to the smaller time frame?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by tonynt, Today, 02:11 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by timcjpfx, Today, 01:18 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_Tyler  
    Started by lordvader34, Today, 12:48 PM
    5 responses
    17 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Started by Newtrader101, Today, 11:06 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Newtrader101, Today, 11:03 AM
    2 responses
    10 views
    0 likes
    Last Post Newtrader101  
    Working...
    X