NexusFi: Find Your Edge


Home Menu

 





Help Drawing Lines Connecting Bars (Indicator Development)


Discussion in NinjaTrader

Updated
    1. trending_up 1,757 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?
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
The 50/50 Paradox: Peace and Invasion Each at 20% -- Ira …
Prediction Markets & Event Contracts
South Korea Suspends Bithumb for Six Months Over AML Fai …
Cryptocurrency
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
24 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
7 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 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