NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-07-2009, 07:47 AM   #1
hondo69
Junior Member
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default Draw Lines for Min / Max Last (N) Bars

I'm trying to draw lines on the price chart that shows the Min and Max price range of the last (n) bars. Can't quite get it right using the Strategy Wizard or editing existing examples in the forum.

Essentially, the two lines would form a channel that draws from the current bar backward. The boundaries of the channel are defined by the Min and Max prices of the previous (n) bars. In the example attached, it uses a value of 8 for (n) bars back. But I also want the lines to extend back past the 8th bar back just so it is more visually appealing.

The idea is to make it apparent when the current bar breaks out of the range of the channel. So an audio alert should be added when price breaks the boundary.

As each new bar closes the channel needs to be redrawn. I'd appreciate ideas from anyone that can help with this indicator.
Attached Images
File Type: jpg minmax_chart.jpg (63.8 KB, 63 views)
hondo69 is offline  
Reply With Quote
Old 11-07-2009, 07:58 AM   #2
Ralph
Senior Member
 
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
Default

Hondo,

this link explains how to draw a line on to the chart without restrictions. Not exactely what you are looking for, but with some modifications it would serve your purpose:

http://www.ninjatrader-support2.com/...0&postcount=10

Regards
Ralph
Ralph is offline  
Reply With Quote
Old 11-09-2009, 11:49 AM   #3
hondo69
Junior Member
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Ralph, that helps. Still having a few issues with it but at least I think I'm on the right track now.
hondo69 is offline  
Reply With Quote
Old 06-13-2010, 08:29 PM   #4
David Lean
Senior Member
 
Join Date: Oct 2009
Location: Australia
Posts: 108
Thanks: 2
Thanked 14 times in 7 posts
Default A simpler way to do this.

Do not go with the PLOT method to solve something as simple as this. Just use OnBarUpdate()




Just use something like :-
  1. Calculate the values for your line. Try the MAX & MIN functions. Ensure you have a parmameter called Period.
Code:
1. Max Function to find the Max High in the past "Period" bars.
double HHV = MAX(High, period)[0];
2. Have another parameter which says how many bars back you want the line to start. eg: LinePeriods

3. then draw the line, starting "LinePeriods" back.
Code:
DrawLine("Rest"+CurrentBar.ToString(), false, LinePeriods, HHV, 0, HHV, Color.LimeGreen, DashStyle.Dot, 2);
4. Then when the High[0] > HHV you have a breakout.
Code:
// Plays the wav file mySound.wav 
PlaySound(@"C:\mySound.wav");
5. Then raise an alert.
Code:
// Generates an alert
Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert1.wav", 10, Color.Black, Color.Yellow);
6. To prevent you indicator from getting errors do not plot anything untill you have sufficient bars. The 1st line in your OnBarsUpdate Method() should be
Code:
if(CurrentBar < LinePeriods )
return.
Hope this helps
David Lean is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
max/min vs number of bars ATI user Version 7 Beta General Questions & Bug Reports 8 10-16-2009 08:45 AM
Max/Min List nfeldberg General Programming 2 07-16-2008 01:22 PM
How can I draw lines behide the candlestick bars? clearpicks General Programming 4 04-22-2008 06:26 PM
MAX/MIN limits Richard Von Indicator Development 3 07-30-2007 08:29 AM
Min / Max mydet Indicator Development 1 05-31-2007 04:47 AM


All times are GMT -6. The time now is 05:15 PM.