• 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

Slope into degrees need ticksize conversion?

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

    Slope into degrees need ticksize conversion?

    I followed the example given in the Slope() method on NT8 guide to convert the slope into degrees as follow:



    Code:
    
    double SlopeExample = Slope(15, 5, 0); //slope of last 5min
    
    
    double degreesExample = Math.Atan(SlopeExample) * (180 / Math.PI);
    However, I am getting different values for different instruments. Do I have to divide or multiple somewhere in the code with the TickSize?



    #2
    Hello Boonfly8,

    Multiplying by the TickSize should not be necessary.

    Are you finding the value of Slope() is unexpected?

    I would expect different instruments slope to be different... Are you measuring these and finding the amount of price change is exactly the same but the slope is a different value?

    Below is a public link to the help guide on Slope().
    https://ninjatrader.com/support/help...n-us/slope.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      After converting the slope to degrees, it seems like the value needs a factor multiplier for some reason. For example, the the degree for ES and CL is that looks like CL needs to be multiplied by 10 to get the values to make sense. You can just copy the formula above and take a look for ES and CL and you'll see the difference. Like you said, I would expect the degree to be a value that is applicable to any and all instruments, but not sure what is happening here.

      Comment


        #4
        To further illustrate, please take a look at the attached two graphs with the same exact indicator formula for finding slope then converting it to degrees.

        Notice the values are drastically different for different markets while market conditions that produced the slope/degree values are not that different.

        Comment


          #5
          Hello Boonfly8,

          You are comparing two different instruments that have different sized movements in the market. One of these is traveling a greater distance than the other. I would not expect two instruments with different tick sizes to have similar slope.

          However, I would need to see that you are performing the math on a calculator and finding the value of the slope is incorrect without using visual charts or plots that can be misleading.

          Are you manually performing the math for slope and finding the Slope() method is returning incorrect values?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            hi Chelsea, to further illustrate, I have attached the slope value for 6E. notice the values are drastically different. Click image for larger version

Name:	6Eslope.jpg
Views:	13
Size:	148.0 KB
ID:	1034858

            The indicator is as follows:

            Code:
            double SlopeSMA = Slope(SMA(15), 5, 0); //slope of last 5min using 15SMA
            
            
            double degreesOutput = Math.Atan(SlopeSMA) * ((180 / Math.PI));
            
            
            Values[0][0] = degreesOutput;
            As you can see, the final output is in degrees after conversion, but the values are in .0000

            This is the same in other markets such as ES and CL.
            Attached Files

            Comment


              #7
              Hello Boonfly8,

              I was not able to confirm, without looking visually, are you manually performing the math for slope and finding the Slope() method is returning incorrect values?

              It would be expected the slope and angle would be different on the ES from 2892.00 to 2892.25 (1 tick) a difference of .25 and the 6E from 1.15540 to 1.15545 (1 tick) a difference of .00005. The slope and angle would be drastically different. I would not expect the slope to be similar between these instruments.
              Last edited by NinjaTrader_ChelseaB; 10-08-2018, 01:57 PM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Look at the chart attached and the output in which I have printed degrees after conversion using the helpguide formula and Slope Value before conversion. Specifically look at the two blue horizontal lines drawn on the chart, the output values in degrees and slope look unreasonable for the market move that happened.

                So back to my original question, how would one standardize the value for angle? A 45* move in ES vs 6E might have different values but a 45* move is a 45* move regardless.

                that's the whole point of converting the values to angle isn't it? So we can standardize different market conditions or market moves to a universal value
                Last edited by Boonfly8; 10-08-2018, 02:11 PM.

                Comment


                  #9
                  Hello Boonfly8,

                  This is based on the price and time (number of bars). The two instruments would need to travel the same distance in price over the same amount of time to have the same slope or angle. Looking at the charts you have provided these have traveled different distances in price and I would not expect the angle to be similar for these instruments.

                  I believe the slope and angles are correct and that these should not be similar.

                  Try adding both instruments to the same chart, in the same panel, using the same scale justification to compare the angles in relation to each other. I am expecting the one that travels in price less to have a flatter angle. The one that travels in price more will have a sharper angle.
                  Traveling .25 over one bar is most definitely not the same angle as travelling .00005 over one bar.

                  To have the angles the same, the distance traveled would need to be the same. You might try to come up with some kind of custom fancy math to multiply an instruments price so that the distances traveled are similar.. However this would be custom logic that you would need to create.

                  However, if you would like to show using a calculator that values and formulas are incorrect I would be happy to report this to our development. I will not be able to report a screenshot a chart. I will need actual numbers you have calculated with a calculator that shows the Slope() method is producing incorrect values.

                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea,

                    Looking at the https://ninjatrader.com/support/help...-us/?slope.htm ... where series is "Any Series<double> type object such as an indicator, Close, High, Low, etc...", then why does NT not attempt to normalize the values by calculating the distance traveled in ticks then dividing by the number of bars? So like you said, instead of each ES increment moving 0.25, and 6E moving 0.00005, it would move 1 tick for both

                    Comment


                      #11
                      Hello Boonfly8,

                      I wouldn't be able to comment on why the price was used instead of a number of ticks when the Slope() method was developed. I am happy to submit a feature request on your behalf for this if you would like.

                      You could also write custom logic in your script to do this. (For example a custom method that measures the slope based on a number of ticks from the first point to the second point and not the y value (price) of each point.)

                      You can also contact a professional NinjaScript Consultant who would be eager to create or modify your script at your request or assist you with modifying your own 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.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by jerblaster23, Today, 03:42 PM
                      1 response
                      9 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by brian meade, Today, 01:39 PM
                      2 responses
                      8 views
                      0 likes
                      Last Post brian meade  
                      Started by Johnny Santiago, Today, 12:20 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_ChrisL  
                      Started by NinjaTrader_Brandon, Today, 10:24 AM
                      0 responses
                      60 views
                      0 likes
                      Last Post NinjaTrader_Brandon  
                      Started by ptertich, Today, 07:56 AM
                      2 responses
                      17 views
                      0 likes
                      Last Post Johnny Santiago  
                      Working...
                      X