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

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 Perr0Grande, Today, 08:16 PM
    0 responses
    2 views
    0 likes
    Last Post Perr0Grande  
    Started by elderan, Today, 08:03 PM
    0 responses
    4 views
    0 likes
    Last Post elderan
    by elderan
     
    Started by algospoke, Today, 06:40 PM
    0 responses
    10 views
    0 likes
    Last Post algospoke  
    Started by maybeimnotrader, Today, 05:46 PM
    0 responses
    9 views
    0 likes
    Last Post maybeimnotrader  
    Started by quantismo, Today, 05:13 PM
    0 responses
    7 views
    0 likes
    Last Post quantismo  
    Working...
    X