NexusFi: Find Your Edge


Home Menu

 





Help Drawing Lines Connecting Bars (Indicator Development)


Discussion in NinjaTrader

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




 
Search this Thread
  #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?
Double Deadlock: Rubio Calls Hormuz Tolls "Unfeasib …
Traders Hideout
CME Raises Energy Futures Margins After Iran-War Volatil …
Commodities
Iran and Israel Stand Down: What $9M in Peace Contracts …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 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
Thanked by:




Last Updated on March 29, 2016


© 2026 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 - Downloads - Top
no new posts