![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Apr 2009
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I'm a NT newbie and trying to create a simple formula for calculating the slope value of the Highest Highs. What I can't figure, however, is how I can extract the number of bar. With the HighestBar() method I can get the number of bars within the lookback period, but how can I get the number of bars ago for the period preceding the current one? Below is the formula (currently not working) for what I am trying to do: Slope1= Slope((MAX(High,ratio)[0]-MAX(High,ratio)[ratio]),1,0); here's I am calculating the Highest High for the current period (say, 5 bars - from 0 to 4th) and the HH for the period from 5th to 9th. Generally speaking, what is there universal method for getting time stamp or # of bars ago for given event? Thanks! |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
msamadov,
You need to store your calculations into a DataSeries before you can run Slope() on it. Please see this article: http://www.ninjatrader-support.com/H...taSeriesObject To get the timestamp of your bars just use Time[0] where 0 is the index of the bar you want the timestamp of.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2011
Posts: 3
Thanks: 0
Thanked 1 time in 1 post
|
How to Find the Slope of a LineBack to Top
Determine the slope of a line, which contains the points A (-1, -2), B (-2, 1): Solution: Here, x1 = -1, x2 = -2, y1 = -2, y2 = 1. Slope of the line, m = [ (y2 - y1)/(x2 - x1)] = [(1 + 2)/(-2 + 1)] = [3/(-1)] Slope of the line (m) = -3 The slope formula of the line is: Slope (m) = [ (y2 - y1)/(x2 - x1)] Slope (m) =Rise / Run (Rise = change in the y co-ordinate; Run = change in the x co-ordinate) In the above given graph, the Rise is given for the points B (4,2) and C (4,4) and the Run is given for the points A (2,2) and B (4,2) Rise = change in the y - coordinate = 4-2 =2 Run = change in the x- coordinate = 4-2 =2 Using the slope formula, we get : Slope( m ) = Rise / Run = 2 / 2 =1
|
|
|
|
|
The following user says thank you to geeknick for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Someone give me a formula | cassb | General Programming | 20 | 04-08-2010 01:26 PM |
| Formula for Fibonacci Extension | richa61416 | Strategy Development | 2 | 07-13-2008 02:15 PM |
| EMA Crossing Formula | pipsheker | General Programming | 1 | 05-18-2008 12:49 PM |
| CCI formula | pipsheker | General Programming | 2 | 05-17-2008 06:57 AM |
| Using a formula or variable as an input to an Indicator | nolantx | Indicator Development | 5 | 05-24-2007 03:58 PM |