NexusFi: Find Your Edge


Home Menu

 





Help Drawing Lines Connecting Bars (Indicator Development)


Discussion in NinjaTrader

Updated
    1. trending_up 1,333 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread

Help Drawing Lines Connecting Bars (Indicator Development)

  #1 (permalink)
jmondanaro
Boston, MA
 
Posts: 2 since Feb 2016
Thanks Given: 1
Thanks Received: 0

Hi all, I'm looking for an example on how to draw a line on a bar chart for automated channel/support resistance indicators. The Vertical Line is easy, but for any other type of line, it isn't clear to me from the documentation how to ensure that a line is draw at a Y coordinate that matches the bar. Two prime examples I'm struggling with are:

1) Just draw a horizontal bar at the top of the highest bar close in the last N bars. Once I find the bar how do I get the line to draw aligned to the top of the bar and how to derive the X length from the current width of bars.

2) I want to draw a line between two bars of some number of bars apart and extending in either direction by an extra N bars.

I'm using NT8, but NT7 examples are fine too.

Thanks,

-Jason

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
Request for MACD with option to use different MAs for fa …
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
67 thanks
Battlestations: Show us your trading desks!
48 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #3 (permalink)
 Maza 
Cluj-Napoca Cluj/Romania
 
Experience: Intermediate
Platform: NinjaTrader, MetaTrader 4
Broker: FXCM, Continuum
Trading: Forex, Futures
Posts: 12 since Apr 2013
Thanks Given: 6
Thanks Received: 7



jmondanaro View Post
Hi all, I'm looking for an example on how to draw a line on a bar chart for automated channel/support resistance indicators. The Vertical Line is easy, but for any other type of line, it isn't clear to me from the documentation how to ensure that a line is draw at a Y coordinate that matches the bar. Two prime examples I'm struggling with are:

1) Just draw a horizontal bar at the top of the highest bar close in the last N bars. Once I find the bar how do I get the line to draw aligned to the top of the bar and how to derive the X length from the current width of bars.

2) I want to draw a line between two bars of some number of bars apart and extending in either direction by an extra N bars.

I'm using NT8, but NT7 examples are fine too.

Thanks,

-Jason

Hello Jason,

From what I read about your issue, I have made some code in NT8 to exemplify what I gathered you need.
 
Code
			int x = 0;
			for(int i = 0; i <= barsBack; i++){
				if(High[x] < High[i])
					x = i;
			}
			Draw.Line(this, "line", x+barsExtend, High[x], x-10-barsExtend, High[x], Brushes.Black);
This code is for the On Bar Update part of the indicator. What this does is it looks for which bar in the last "barsBack" (this you can have as a variable) number of bars back has the highest high and records the bar number. The draw line part of the code draws a line that will be over ridden on each new draw (bar), from the bar that gave you the highest high with "barsExtend" (this is a variable of type int) to the left, the y co-ordinate of the line remains the same so you draw just a horizontal line and the second x co-ordinate is the x bar minus a variable that you can change and minus the "barsExtend" again so it extends to the right of the bar that you wanted.

Hope this helped,

Maza.

Reply With Quote
The following user says Thank You to Maza for this post:





Last Updated on March 29, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts