Code snippet for calculating slope - NinjaTrader Programming | futures io social day trading
futures io futures trading


Code snippet for calculating slope
Updated: Views / Replies:4,667 / 2
Created: by Saroj Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Code snippet for calculating slope

  #1 (permalink)
Elite Member
Arcata, CA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
 
Saroj's Avatar
 
Posts: 482 since Jun 2009
Thanks: 223 given, 389 received

Code snippet for calculating slope

This is an example of one form that I picked up from a strategy posted by wh. This example is for the 20 simple moving average. You can substitute any series based value for SMA(20) whether it be a standard NT indicator or a custom indicator. The TickSize will modify the scale for the instrument of the chart.


sma20slope = (int)(radToDegrees*(Math.Atan((SMA(20)[0]-(SMA(20)[1]+SMA(20)[2])/2)/1.5/TickSize)));

include the following in the variables section:
privatedouble radToDegrees = 180/Math.PI;
privateint sma20slope = 0;

I have just started using it so I can't comment on how well it works, but you could use a series for the slope result instead of an integer and plot it in a panel for testing. Please report back on your findings.

Reply With Quote
The following user says Thank You to Saroj for this post:
 
  #2 (permalink)
Elite Member
Leipzig / Germany
 
Futures Experience: Intermediate
Platform: NT / TS, MC and Clones
Broker/Data: Interactive Broker
Favorite Futures: Futures, Forex
 
Posts: 24 since Aug 2009
Thanks: 31 given, 34 received

Feedback for slope calculation

at first - thanks for the snippet

this is the common formula with two enhancements.
- the usage of two older Values (like a "mini" Moving Average) results in a more stable Slope-Calculation
- consider the Ticksize try to standardize price-skales with different amount.

The Snippet DID NOT WORK on Indikators, which oszillate between positiv and negativ Values.

--> you can use the common Slope() Command.

Degree = Slope(SMA(14), 1, 0) / Ticksize;

The Ticksize Standardization is imprecise, because it gives us no adjustment if you switch between a 1Minute and 10 Minute Timeframe, and it also did not differenciate between price-data and indicator-data (i.e. from -1 to +1).

best
Trendseek

Reply With Quote
 
  #3 (permalink)
Elite Member
Houston,Tx
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: TF
 
ThatManFromTexas's Avatar
 
Posts: 2,302 since Feb 2010
Thanks: 1,208 given, 4,293 received



Saroj View Post
This is an example of one form that I picked up from a strategy posted by wh. This example is for the 20 simple moving average. You can substitute any series based value for SMA(20) whether it be a standard NT indicator or a custom indicator. The TickSize will modify the scale for the instrument of the chart.


sma20slope = (int)(radToDegrees*(Math.Atan((SMA(20)[0]-(SMA(20)[1]+SMA(20)[2])/2)/1.5/TickSize)));

include the following in the variables section:
privatedouble radToDegrees = 180/Math.PI;
privateint sma20slope = 0;

I have just started using it so I can't comment on how well it works, but you could use a series for the slope result instead of an integer and plot it in a panel for testing. Please report back on your findings.

This formula is from Woodies CCIClub. Ken Wood (Woodie) uses a calculation of 1.5 bars back . Hence the
 
Code
(SMA(20)[1]+SMA(20)[2])/2)/1.5


Slope is calculated on Rise/Run (From where we are how many bars back).

You can add a variable for Barsback.

emaslope = (int)(radToDegrees*(Math.Atan((EMA(Period)[0]-EMA(Period)[BarsBack])/BarsBack/TickSize)));

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote

Reply



futures io > > > > > Code snippet for calculating slope

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of Rising() and Slope() MXASJ NinjaTrader Programming 17 August 13th, 2011 12:31 PM
Using slope of an indicator in an auto-strategy nanobiotech NinjaTrader Programming 4 August 6th, 2010 12:31 PM
Calculating 'Perfect Profit' Jura NinjaTrader Programming 6 July 15th, 2010 08:25 AM
Calculating the slope of _ADXVMA_Alertsv01_5_1 nanobiotech NinjaTrader Programming 3 April 6th, 2010 01:35 PM
Round to interval: code snippet + problem gregid NinjaTrader Programming 3 December 9th, 2009 09:02 PM


All times are GMT -4. The time now is 06:40 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-12 in 0.11 seconds with 19 queries on phoenix via your IP 54.145.51.250