NexusFi: Find Your Edge


Home Menu

 





Shorter vertical line with DrawLine


Discussion in NinjaTrader

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




 
Search this Thread

Shorter vertical line with DrawLine

  #1 (permalink)
 Randwulf 
Colorado Springs, CO
 
Experience: Beginner
Platform: NinjaTrader
Posts: 22 since Oct 2009
Thanks Given: 16
Thanks Received: 0

I'm currently using DrawRegion() from the top to the bottom of a Keltner Channel to highlight a bar.
I like this approach except for the fact that it offsets by half a bar.

I could be just as happy with a vertical line that runs from top to bottom of the channel but,
I can't seem to get DrawLine() to work...
At present, if the bool for autoscale is "false", the lines don't show and if "true", they do show but, run considerably higher and lower than the channel.

Example:
protected override void OnBarUpdate()
{
// Condition set 1
if (High[0] > KeltnerChannel(4, 50).Midline[0]
&& Low[0] < KeltnerChannel(4, 50).Midline[0])
{
DrawLine("My line" + CurrentBar, false, 0, KeltnerChannel(4, 50).Upper[0], 0, KeltnerChannel(4, 50).Lower[0] , Color.White, DashStyle.Solid, 2);
}
}

Here's the point where you smile and shake your head...
Go ahead, please show me the error of my ways...

Thanks in advance

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
31 thanks
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
anachronist's Avatar
 anachronist 
San Jose, CA
 
Experience: Advanced
Platform: NinjaTrader
Trading: all
Posts: 27 since Apr 2012
Thanks Given: 0
Thanks Received: 16


Regarding your statement:
DrawLine("My line" + CurrentBar, false, 0, KeltnerChannel(4, 50).Upper[0], 0, KeltnerChannel(4, 50).Lower[0] , Color.White, DashStyle.Solid, 2);

I don't know if this will fix your problem, but I'd do a couple things differently.

1. The line ID "My line"+CurrentBar should be "My line" + CurrentBar.ToString().

2. You are needlessly recalculating the KeltnerChannel multiple times. To avoid this, here's what I do (and it becomes critical to speed up very complex code).

In variables, declare
 
Code
                            
private KeltnerChannel kc
Add an OnStartUp() to initialize kc (don't put this in Initialize()):
 
Code
                            
protected override void OnStartUp() {
   
kc KelternChannel(450);

Then in OnBarUpdate() do this:
 
Code
                            
protected override void OnBarUpdate() {
   
double k kc[0]; // calculate KeltnerChannel ONCE
   // now access all the properties you want
   
DrawLine("Myline"+CurrentBar.ToString(), false0kc.Upper[0], 0kc.Lower[0] , Color.WhiteDashStyle.Solid2);

-Alex

Reply With Quote
Thanked by:
  #4 (permalink)
 Randwulf 
Colorado Springs, CO
 
Experience: Beginner
Platform: NinjaTrader
Posts: 22 since Oct 2009
Thanks Given: 16
Thanks Received: 0

anachronist,

Thank you for the response.
I wanted to let you know that I appreciate it but, can't validate it just yet.
I am in the process of re-imaging windows and reloading NinjaTrader as NT support can't duplicate the issue.
I especially appreciate the speed up suggestions & will follow up ASAP..

Started this thread Reply With Quote




Last Updated on May 3, 2012


© 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